Part Number Hot Search : 
4HCT3 SERIES N60UF 0515D LTC40 MCIMX 50N024 26706VMM
Product Description
Full Text Search
 

To Download SAB80C535-16-N-T85 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  user ' s manual 08.95 microcomputer components sab 80 5 1 5 / sab 80c 5 1 5 8-bit single-chip microcontroller family
edition 08.95 published by siemens ag, bereich halbleiter, marketing- kommunikation, balanstra?e 73, 81541 mnchen ? siemens ag 1995. all rights reserved. attention please! as far as patents or other rights of third parties are concerned, liability is only assumed for components, not for application s, processes and circuits implemented within components or assemblies. the information describes the type of component and shall not be considered as assured characteristics. terms of delivery and rights to change design reserved. for questions on technology, delivery and prices please contact the semiconductor group offices in germany or the siemens compa nies and representatives worldwide (see address list). due to technical requirements components may contain dangerous substances. for information on the types in question please cont act your nearest siemens office, semiconductor group. siemens ag is an approved cecc manufacturer. packing please use the recycling operators known to you. we can also help you C get in touch with your nearest sales office. by agreeme nt we will take packing material back, if it is sorted. you must bear the costs of transport. for packing material that is returned to us unsorted or which we are not obliged to accept, we shall have to invoice you for an y costs in- curred. components used in life-support devices or systems must be expressly authorized for such purpose! critical components 1 of the semiconductor group of siemens ag, may only be used in life-support devices or systems 2 with the express written approval of the semiconductor group of siemens ag. 1 a critical component is a component used in a life-support device or system whose failure can reasonably be expected to cause the failure of that life-support device or system, or to affect its safety or effectiveness of that device or system. 2 life support devices or systems are intended (a) to be implanted in the human body, or (b) to support and/or maintain and sust ain hu- man life. if they fail, it is reasonable to assume that the health of the user may be endangered. sab 80515 / sab 80c515 family revision history: 8.95 previous releases: 12.90/10.92 page subjects (changes since last revision) 30 39 80 105 106 109 137 152 243 301 modified timing diagram (psen rising edge) more detailed description of acmos port structure differential output impedance of analog reference supply voltage now: 1 k w second paragraph: additional description; wdt reset information added swdt reset information added figure 7-51 corrected encoding of add a, direct corrected encoding of cpl bit corrected new release of sab 80c515 / sab 80c535 data sheet inserted new release of sab 80515 / sab 80535 data sheet inserted
contents contents page semiconductor group 3 1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6 2 fundamental structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10 2.1 differences between mymos (sab 80515/80535) and acmos (sab 80c515/80c535) versions . . . . . . . . . . . . . . . . . . . . . . . . . . .13 2.1.1 power saving modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13 2.1.2 special function register pcon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13 2.1.3 port driver circuitries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14 2.1.4 the a/d converter input ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14 2.1.5 a/d converter timings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15 2.1.6 the oscillator and clock circuits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15 2.1.7 the v bb pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15 3 central processing unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16 3.1 general description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16 3.2 cpu timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17 4 memory organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19 4.1 program memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19 4.2 data memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19 4.3 general purpose register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23 4.4 special function registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23 5 external bus interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .27 5.1 accessing external memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .27 5.2 psen, program store enable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29 5.3 ale, address latch enable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29 5.4 overlapping external data and program memory spaces . . . . . . . . . . . . . .29 6 system reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31 6.1 hardware reset and power-up reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31 6.1.1 reset function and circuitries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31 6.1.2 hardware reset timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .34 7 on-chip peripheral components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .35 7.1 parallel i/o . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .35 7.1.1 port structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .35 7.1.1.1 digital i/o port circuitry (mymos/acmos) . . . . . . . . . . . . . . . . . . . . . . . . .36 7.1.1.2 mymos port driver circuitry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .39 7.1.1.3 acmos port driver circuitry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .39 7.1.2 port 0 and port 2 used as address/data bus . . . . . . . . . . . . . . . . . . . . . . . .41 7.1.3 alternate functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .42 7.1.4 port handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .44 7.1.4.1 port timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .44
contents contents page semiconductor group 4 7.1.4.2 port loading and interfacing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .45 7.1.4.3 read-modify-write feature of ports 0 through 5 . . . . . . . . . . . . . . . . . . . . . .45 7.2 serial interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .47 7.2.1 operating modes of serial interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .47 7.2.2 multiprocessor communication feature . . . . . . . . . . . . . . . . . . . . . . . . . . . .50 7.2.3 baud rates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .50 7.2.4 detailed description of the operating modes . . . . . . . . . . . . . . . . . . . . . . . .54 7.2.4.1 mode 0, synchronous mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .54 7.2.4.2 mode 1, 8-bit uart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .55 7.2.4.3 mode 2, 9-bit uart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .57 7.2.4.4 mode 3, 9-bit uart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .57 7.3 timer 0 and timer 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .65 7.3.1 mode 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .68 7.3.2 mode 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .69 7.3.3 mode 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .70 7.3.4 mode 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .71 7.4 a/d converter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .72 7.4.1 function and control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .74 7.4.1.1 lnitialization and input channel selection . . . . . . . . . . . . . . . . . . . . . . . . . . .74 7.4.1.2 start of conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .75 7.4.2 reference voltages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .76 7.4.3 a/d converter timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .80 7.5 timer 2 with additional compare/capture/reload . . . . . . . . . . . . . . . . . . . . .82 7.5.1 timer 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .85 7.5.2 compare function of registers crc, cc1 to cc3 . . . . . . . . . . . . . . . . . . . .88 7.5.2.1 compare mode 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .88 7.5.2.2 compare mode 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .92 7.5.2.3 using interrupts in combination with the compare function . . . . . . . . . . . . .94 7.5.3 capture function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .96 7.6 power saving modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .98 7.6.1 power saving modes of the sab 80515/80535 . . . . . . . . . . . . . . . . . . . . . . .99 7.6.1.1 power-down mode of the sab 80515/80535 . . . . . . . . . . . . . . . . . . . . . . . .99 7.6.2 power saving modes of the sab 80515/80535 . . . . . . . . . . . . . . . . . . . . . .100 7.6.2.1 power-down mode of the sab 80c515/80c535 . . . . . . . . . . . . . . . . . . . . .101 7.6.2.2 idle mode of the sab 80c515/80c535 . . . . . . . . . . . . . . . . . . . . . . . . . . . .102 7.7 watchdog timer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .105
contents contents page semiconductor group 5 7.8 oscillator and clock circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .107 7.8.1 crystal oscillator mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .107 7.8.2 driving for external source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .107 7.8.2.1 driving the sab 80515/80535 from external source . . . . . . . . . . . . . . . . . .108 7.8.2.2 driving the sab 80c515/80c535 from external source . . . . . . . . . . . . . . .109 7.9 system clock output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .110 8 interrupt system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .112 8.1 interrupt structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .112 8.2 priority level structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .120 8.3 how interrupts are handled . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .122 8.4 external interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .125 8.5 response time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .126 9 instruction set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .127 9.1 addressing modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .127 9.2 introduction to the instruction set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .129 9.2.1 data transfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .129 9.2.2 arithmetic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .130 9.2.3 logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .132 9.2.4 control transfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .132 9.3 instruction definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .134 10 device specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .214
semiconductor group 6 introduction 1 introduction the sab 80c515/80c535 is a new, powerful member of the siemens sab 8051 family of 8-bit microcontrollers. lt is designed in siemens acmos technology and is functionally compatible with the sab 80515/80535 devices designed in mymos technology. the acmos and the mymos versions 1) 2) are stand-alone, high-performance single-chip microcontrollers based on the sab 8051/80c51 architecture. while maintaining all the sab 80(c)51 operating characteristics, the sab 80(c)515/80(c)535 3) incorporate several enhancements which significantly increase design flexibility and overall system performance. the low-power properties of siemens acmos technology allow applications where power consumption and dissipation are critical. furthermore, the sab 80c515/80c535 has two software- selectable modes of reduced activity for further power reduction: idle and power-down mode. the sab 80(c)535 is identical to the sab 80(c)515 except that it lacks the on-chip program memory. the sab 80(c)515/80(c)535 is supplied in a 68-pin plastic leaded chip carrier package (p-lcc-68). in addition to the standard temperature range version (0 to + 70 c) there are also versions for extended temperature ranges available (see data sheets). functional description the members of the sab 80515 family of microcontrollers are: C sab 80c515: microcontroller, designed in siemens acmos technology, with 8-kbyte factory mask-programmable rom C sab 80c535: rom-less version, identical to the sab 80c515 C sab 80515: microcontroller, designed in siemens mymos technology, with 8-kbyte factory mask-programmable rom C sab 80535: rom-less version, identical to the sab 80515 C sab 80515k: special rom-less version of the sab 80515 with an additional interface for program memory accesses. an external rom that is accessed via the interface substitutes the sab 80515s internal rom. 1 in this users manual the term "acmos versions" is used to refer to both the sab 80c515 and sab 80c535. 2 the term "mymos versions" stands for sab 80535 and sab 80515. 3 the term "sab 80(c)515" refers to the sab 80515 and the sab 80c515, unless otherwise noted.
semiconductor group 7 introduction the sab 80(c)515 features are: C 8 kbyte on-chip program memory C 256 byte on-chip ram C six 8-bit parallel i/o ports C one input port for digital input 1) C full-duplex serial port, 4 modes of operation, fixed or variabie baud rates C three 16-bit timer/counters C 16-bit reload, compare, capture capability C a/d converter, 8 multiplexed analog inputs, programmable reference voltages C 16-bit watchdog timer C power-down supply for 40 byte of ram C boolean processor C 256 directly addressable bits C 12 interrupt sources (7 external, 5 internal), 4 priority levels C stack depth up to 256 byte C1 m s instruction cycle at 12-mhz operation C4 m s multiply and divide C external program and data memory expandable up to 64 kbyte each C compatible with standard sab 8080/8085 peripherals and memories C space-saving p-lcc-68 package for small-quantity applications and system development the sab 80535 can be employed being the equivalent of an sab 80515 without on-chip rom. 1 additional feature of the acmos versions
semiconductor group 8 introduction figure 1-1 shows the logic symbol, figure 1-2 the block diagram of the sab 80(c)515: figure 1-1 logic symbol
semiconductor group 9 introduction figure 1-2 block diagram
semiconductor group 10 fundamental structure 2 fundamental structure the sab 80(c)515/80(c)535 is a totally 8051-compatible microcontroller while its peripheral performance has been increased significantly. some of the various peripherals have been added to support the 8-bit core in case of stringent embedded control requirements without loosing compatibility to the 8051 architecture. furthermore, the sab 80(c)515/80(c)535 contains e. g. an additional 8-bit a/d converter, two times as much rom and ram as the 80(c)51 and an additional timer with compare/capture/reload facilities for all kinds of digital signal processing. figure 2.1 shows a block diagram of the sab 80(c)515/80(c)535. the sab 80c515/80c535 combines the powerful architecture of the industry standard controller sab 80515/80535 with the advantages of the acmos technology (e. g. power-saving modes). the differences between mymos and acmos components are explained in section 2.1. readers who are familiar with the sab 8051 may concentrate on chapters 2.1, 6, 7 and 8 where the differences between mymos and acmos components, the reset conditions, the peripherals and the interrupt system are described. for newcomers to the 8051 family of microcontrollers, the following section gives a general view of the basic characteristics of the sab 80515/80535. the details of operation are described later in chapters 3 and 4.
semiconductor group 11 fundamental structure central processing unit the cpu is designed to operate on bits and bytes. the instructions, which consist of up to 3 bytes, are performed in one, two or four machine cycles. one machine cycle requires twelve oscillator cycles. the instruction set has extensive facilities for data transfer, logic and arithmetic instructions. the boolean processor has its own full-featured and bit-based instructions within the instruction set. the sab 80(c)515/80(c)535 uses five addressing modes: direct access, immediate, register, register indirect access, and for accessing the external data or program memory portions a base register plus index-register indirect addressing. memory organization the sab 80c515, 80515 have an internal rom of 8 kbyte. the program memory can externally be expanded up to 64 kbyte (see bus expansion control). the internal ram consists of 256 bytes. within this address space there are 128 bit-addressable locations and four register banks, each with 8 general purpose registers. in addition to the internal ram there is a further 128-byte address space for the special function registers, which are described in sections to follow. because of its harvard architecture, the sab 80(c)515/80(c)535 distinguishes between an external program memory portion (as mentioned above) and up to 64 kbyte external data memory accessed by a set of special instructions. bus expansion control the external bus interface of the sab 80(c)515/80(c)535 consists of an 8-bit data bus (port 0), a 16-bit address bus (port 0 and port 2) and five control lines. the address latch enable signal (ale) is used to demultiplex address and data of port 0. the program memory is accessed by the program store enable signal (psen ) twice a machine cycle. a separate external access line (ea ) is used to inform the controller while executing out of the lower 8 kbyte of the program memory, whether to operate out of the internal or external program memory. the read or write strobe (rd , wr ) is used for accessing the external data memory. peripheral control all on-chip peripheral components - i/o ports, serial interface, timers, compare/capture registers, the interrupt controller and the a/d converter - are handled and controlled by the so-called special function registers. these registers constitute the easy-to-handle interface with the peripherals. this peripheral control concept, as implemented in the sab 8051, provides the high flexibility for further expansion as done in the sab 80(c)515/80(c)535. moreover some of the special function registers, like accumulator, b-register, program status word (psw), stack pointer (sp) and the data pointer (dptr) are used by the cpu and maintain the machine status.
semiconductor group 12 fundamental structure figure 2-1 detailed block diagram
semiconductor group 13 fundamental structure 2.1 differences between mymos (sab 80515/80535) and acmos (sab 80c515/80c535) versions there are some differences between mymos and acmos versions concerning: C power saving modes C special function register pcon C port driver circuitry C a/d converter input ports C a/d converter conversion time C oscillator and clock circuit C v bb pin 2.1.1 power saving modes the sab 80515/80535 has just the power-down mode, which allows retention of the on-chip ram contents through a backup supply connected to the v pd pin. the sab 80c515/80c535 additionally has the following features: C idle mode C the same power supply pin v cc for active, power-down and idle mode C an extra pin (pe ) that allows enabling/disabling the power saving modes C starting of the power-saving modes by software via special function register pcon (power control register) C protection against unintentional starting of the power-saving modes these items are described in detail in section 7.6. 2.1.2 special function register pcon in the mymos version sab 80515/80535 the sfr pcon (address 87 h ) contains only bit 7 (smod). in the acmos version sab 80c515/80c535 there are additional bits used ( see figure 2-2 ). the bits pde, pds and idle, idls select the power-down mode or idle mode, respectively, when the power saving modes are enabled by pin pe . furthermore, register pcon of the acmos version contains two general-purpose flags. for example, the flag bits gf0 and gf1 can be used to indicate whether an interrupt has occurred during normal operation or during idle. then an instruction that activates idle can also set one or both flag bits. when idle is terminated by an interrupt, the interrupt service routine can sample the flag bits.
semiconductor group 14 fundamental structure 2.1.3 port driver circuitries the port structures of the mymos and acmos versions are functionally compatible. for low power consumption the pullup arrangement is realized differently in both versions. chapters 7.1.1.1, 7.1.1.2, 7.1.1.3 are dealing with the port structures in detail. 2.1.4 the a/d converter input ports the analog input ports (an0 to an7) of the sab 80515/80535 can only be used as analog inputs for the a/d converter. the analog input ports (p6.0 to p6.7) of the sab 80c515/80c535 can be used either as input channels for the a/d converter or as digital inputs (see chapter 7.4) figure 2-2 special function register pcon (address 87 h ) symbol position function smod pds idls C gf1 gf0 pde idle pcon.7 pcon.6 pcon.5 pcon.4 pcon.3 pcon.2 pcon.1 pcon.0 when set, the baud rate of the serial channel in mode 1, 2, 3 is doubled. power-down start bit. the instruction that sets the pds flag bit is the last instruction before entering the power-down mode. idle start bit. the instruction that sets the idls flag bit is the last instruction before entering the idle mode. reserved general purpose flag general purpose flag power-down enable bit. when set, starting of the power-down mode is enabled. idle mode enable bit. when set, starting of the idle mode is enabled. these bits are available in the mymos version smod pds idls C gf1 gf0 pde idle 87 h pcon 76543210
semiconductor group 15 fundamental structure 2.1.5 a/d converter timings see the corresponding data sheets for the specification of t l (load time), t s (sample time), t c (conversion time). 2.1.6 the oscillator and clock circuits there is no difference between the mymos and acmos versions if they are driven from a crystal or a ceramic resonator. please note that there is a difference between driving mymos and acmos components from external source. how to drive each device is described in chapter 7.8.2 and in each data sheet. 2.1.7 the v bb pin the sab 80515/80535 has an extra v bb pin connected to the devices substrate. lt must be connected to v ss through a capacitor for proper operation of the a/d converter. the sab 80c515/80c535 has no v bb pin. in acmos technology the substrate is directly connected to v cc ; therefore, the corresponding pin is used as an additional v cc pin.
semiconductor group 16 central processing unit 3 central processing unit 3.1 general description the cpu (central processing unit) of the sab 80(c)515 consists of the instruction decoder, the arithmetic section and the program control section. each program instruction is decoded by the instruction decoder. this unit generates the internal signals controlling the functions of the individual units within the cpu. they have an effect on the source and destination of data transfers, and control the alu processing. the arithmetic section of the processor performs extensive data manipulation and is comprised of the arithmetic/logic unit (alu), an a register, b register and psw register. the alu accepts 8-bit data words from one or two sources and generates an 8-bit result under the control of the instruction decoder. the alu performs the arithmetic operations add, subtract, multiply, divide, increment, decrement, bcd-decimal-add-adjust and compare, and the logic operations and, or, exclusive or, complement and rotate (right, left or swap nibble (left four)). also included is a boolean processor performing the bit operations of set, clear, complement, jump-if-not-set, jump-if-set-and- clear and move to/from carry. between any addressable bit (or its complement) and the carry flag, it can perform the bit operations of logical and or logical or with the result returned to the carry flag. the a, b and psw registers are described in section 4.4. the program control section controls the sequence in which the instructions stored in program memory are executed. the 16-bit program counter (pc) holds the address of the next instruction to be executed. the pc is manipulated by the control transfer instructions listed in the chapter "instruction set". the conditional branch logic enables internal and external events to the processor to cause a change in the program execution sequence.
semiconductor group 17 central processing unit 3.2 cpu timing a machine cycle consists of 6 states (12 oscillator periods). each state is divided into a phase 1 half, during which the phase 1 clock is active, and a phase 2 half, during which the phase 2 clock is active. thus, a machine cycle consists of 12 oscillator periods, numbered s1p1 (state 1, phase 1) through s6p2 (state 6, phase 2). each state lasts for two oscillator periods. typically, arithmetic and logical operations take place during phase 1 and internal register-to-register transfers take place during phase 2. the diagrams in figure 3-1 show the fetch/execute timing related to the internal states and phases. since these internal clock signals are not user-accessible, the xtal2 oscillator signals and the ale (address latch enable) signal are shown for external reference. ale is normally activated twice during each machine cycle: once during s1p2 and s2p1, and again during s4p2 and s5p1. execution of a one-cycle instruction begins at s1p2, when the op-code is latched into the instruction register. lf it is a two-byte instruction, the second is read during s4 of the same machine cycle. lf it is a one-byte instruction, there is still a fetch at s4, but the byte read (which would be the next op- code) is ignored, and the program counter is not incremented. in any case, execution is completed at the end of s6p2. figures 3-1 a) and b) show the timing of a 1-byte, 1-cycle instruction and for a 2-byte, 1-cycle instruction. most sab 80(c)515 instructions are executed in one cycle. mul (multiply) and div (divide) are the only instructions that take more than two cycles to complete; they take four cycles. normally two code bytes are fetched from the program memory during every machine cycle. the only exception to this is when a movx instruction is executed. movx is a one-byte, 2-cycle instruction that accesses external data memory. during a movx, the two fetches in the second cycle are skipped while the external data memory is being addressed and strobed. figures 3-1 c) and d) show the timing for a normal 1-byte, 2-cycle instruction and for a movx instruction.
semiconductor group 18 central processing unit figure 3-1 fetch/execute sequence
semiconductor group 19 memory organization 4 memory organization the sab 80(c)515 cpu manipulates operands in the following four address spaces: C up to 64 kbyte of program memory C up to 64 kbyte of external data memory C 256 bytes of internal data memory C a 128-byte special function register area 4.1 program memory the program memory of the sab 80(c)515 consists of an internal and an external memory portion ( see figure 4-1 ). 8 kbyte of program memory may reside on-chip (sab 80c515/80515 only), while the sab 80c535/80535 has no internal rom. the program memory can be externally expanded up to 64 kbyte. if the ea pin is held high, the sab 80(c)515 executes out of the internal program memory unless the address exceeds 1fff h . locations 2000 h through 0ffff h are then fetched from the external memory. if the ea pin is held low, the sab 80(c)515 fetches all instructions from the external program memory. since the sab 80c535/80535 has no internal program memory, pin ea must be tied low when using this device. in either case, the 16-bit program counter is the addressing mechanism. locations 03 h through 93 h in the program memory are used by interrupt service routines. 4.2 data memory the data memory address space consists of an internal and an external memory portion. internal data memory the internal data memory address space is divided into three physically separate and distinct blocks: the lower 128 bytes of ram, the upper 128-byte ram area, and the 128-byte special function register (sfr) area ( see figure 4-2 ). since the latter sfr area and the upper ram area share the same address locations, they must be accessed through different addressing modes. the map in figure 4-2 and the following table show the addressing modes used for the different ram/ sfr spaces.
semiconductor group 20 memory organization for details about the addressing modes see chapter 9.1. figure 4-1 program memory address space the lower 128 bytes of the internal ram are again grouped in three address spaces ( see figure 4-3 ): 1) a general purpose register area occupies locations 0 through 1f h (see also section 4.3). 2) the next 16 bytes, location 20 h through 2f h , contain 128 directly addressable bits. programming information: these bits can be referred to in two ways, both of which are acceptable for the asm51. one way is to refer to their bit addresses, i.e. 0 to 7f h . the other way is by referencing to bytes 20 h to 2f h . thus bits 0 to 7 can also be referred to as bits 20.0 to 20.7, and bits 08 h and 0f h are the same as 21.0 to 21.7 and so on. each of the 16 bytes in this segment may also be addressed as a byte.) 3) locations 30 h to 7f h can be used as a scratch pad area. address space locations addressing mode lower 128 bytes of ram 00 h to 7f h direct/indirect upper 128 bytes of ram 80 h to 0ff h indirect special function registers 80 h to 0ff h direct
semiconductor group 21 memory organization using the stack pointer (sp) - a special function register described in section 4.4 - the stack can be located anywhere in the whole internal data memory address space. the stack depth is limited only by the internal ram available (256 byte maximum). however, the user has to take care that the stack is not overwritten by other data, and vice versa. external data memory figure 4-2 and 4-3 contain memory maps which illustrate the internal/external data memory. to address data memory external to the chip, the "movx" instructions in combination with the 16-bit datapointer or an 8-bit general purpose register are used. refer to chapter 9 (instruction set) or 5 (external bus interface) for detailed descriptions of these operations. a maximum of 64 kbytes of external data memory can be accessed by instructions using 16-bit address. figure 4-2 data memory / sfr address space
semiconductor group 22 memory organization figure 4-3 mapping of the lower portion of the internal data memory
semiconductor group 23 memory organization 4.3 general purpose register the lower 32 locations of the internal ram are assigned to four banks with eight general purpose register (gprs) each. only one of these banks may be enabled at a time. two bits in the program status word, psw.3 and psw.4, select the active register bank (see description of the psw). this allows fast context switching, which is useful when entering subroutines or interrupt service routines. asm51 and the device sab 80(c)515 default to register bank 0. the 8 general purpose registers of the selected register bank may be accessed by register addressing. with register addressing the instruction op code indicates which register is to be used. for indirect accessing r0 and r1 are used as pointer or index register to address internal or external memory (e.g. mov @r0). reset initializes the stack pointer to location 07 h and increments it once to start from location 08 h which is also the first register (r0) of register bank 1. thus, if one is going to use more than one register bank, the sp should be initiated to a different location of the ram which is not used for data storage. 4.4 special function registers the special function register (sfr) area has two important functions. firstly, all cpu register except the program counter and the four register banks reside here. the cpu registers are the arithmetic registers like a, b, psw and pointers like sp, dph and dpl. secondly, a number of registers constitute the interface between the cpu and all on-chip peripherals. that means, all control and data transfers from and to the peripherals use this register interface exclusively. the special function register area is located in the address space above the internal ram from addresses 80 h to ff h . all 41 special function registers of the sab 80(c)515 reside here. fifteen sfrs, that are located on addresses dividable by eight, are bit-addressable, thus allowing 128 bit-addressable locations within the sfr area. since the sfr area is memory mapped, access to the special function registers is as easy as with internal ram, and they may be processed with most instructions. in addition, if the special functions are not used, some of them may be used as general scratch pad registers. note, however, all sfrs can be accessed by direct addressing only. the special function registers are listed in table 4-1 . bit- and byte-addressable special function registers are marked with an asterisk at the symbol name.
semiconductor group 24 memory organization table 4-1 special function registers the sfrs marked with an asterisk (*) are bit- and byte-addressable. 1) additional feature of the acmos versions symbol name address *p0 sp dpl dph pcon *tcon tmod tl0 tl1 th0 th1 *p1 *scon sbuf *p2 *ien0 ip0 *p3 *ien1 ip1 *ircon ccen ccl1 cch1 ccl2 cch2 ccl3 cch3 *t2con crcl crch tl2 th2 *psw * adcon addat dapr p6 *acc *p4 *b *p5 port 0 stack pointer data pointer, low byte data pointer, high byte power control register timer control register timer mode register timer 0, low byte timer 1, low byte timer 0, high byte timer 1, high byte port 1 serial channel control register serial channel buffer register port 2 interrupt enable register 0 interrupt priority register 0 port 3 interrupt enable register 1 interrupt priority register 1 interrupt request control register compare/capture enable register compare/capture register 1, low byte compare/capture register 1, high byte compare/capture register 2, low byte compare/capture register 2, high byte compare/capture register 3, low byte compare/capture register 3, high byte timer 2 control register compare/reload/capture register, low byte compare/reload/capture register, high byte timer 2, low byte timer 2, high byte program status word register a/d converter control register a/d converter data register d/a converter program register port 6 accumulator port 4 b register port 5 80 h 81 h 82 h 83 h 87 h 88 h 89 h 8a h 8b h 8c h 8d h 90 h 98 h 99 h 0a0 h 0a8 h 0a9 h 0b0 h 0b8 h 0b9 h 0c0 h 0c1 h 0c2 h 0c3 h 0c4 h 0c5 h 0c6 h 0c7 h 0c8 h 0ca h 0cb h 0cc h 0cd h 0d0 h 0d8 h 0d9 h 0da h 0db h 1) 0e0 h 0e8 h 0f0 h 0f8 h
semiconductor group 25 memory organization the following paragraphs give a general overview of the special function register and refer to sections where a more detailed description can be found. accumulator, sfr address 0e0 h acc is the symbol for the accumulator register. the mnemonics for accumulator-specific instructions, however, refer to the accumulator simply as a. figure 4-4 program status word register (psw), sfr address 0d0 h the psw register contains program status information. b register, spf address 0f0 h the b register is used during multiply and divide and serves as both source and destination. for other instructions it can be treated as another scratch pad register. stack pointer, sfr address 081 h the stack pointer (sp) register is 8 bits wide. it is incriminated before data is stored during push and call executions and decremented after data is popped during a pop and ret (reti) execution, i.e. it always points to the last valid stack byte. while the stack may reside anywhere in on-chip ram, the stack pointer is initialized to 07 h after a reset. this causes the stack to begin at location 08 h above register bank zero. the sp can be read or written under software control. bit function cy carry flag ac auxiliary carry flag (for bcd operations) f0 general purpose user flag 0 rs1 rs0 00 01 10 11 register bank select control bits bank 0 selected, data address 00 h - 07 h bank 1 selected, data address 08 h - 0f h bank 2 selected, data address 10 h - 17 h bank 3 selected, data address 18 h - 1f7 ov overflow flag f1 general purpose user flag p parity flag. set/cleared by hardware each instruction cycle to indicate an odd/ even number of "one" bits in the accumulator, i.e. even parity. 0d7 h 0d6 h 0d5 h 0d4 h 0d3 h 0d2 h 0d1 h 0d0 h cy ac f0 rs1 rs0 ov f1 p 0d0 h psw
semiconductor group 26 memory organization datapointer, sfr address 082 h and 083 h the 16-bit datapointer (dptr) register is a concatenation of registers dph (data pointers high order byte) and dpl (data pointers low order byte). the data pointer is used in register-indirect addressing to move program memory constants and external data memory variables, as well as to branch within the 64 kbyte program memory address space. ports 0 to 5 p0 to p5 are the sfr latches to port 0 to 5, respectively. the port sfrs 0 to 5 are bit-addressable. ports 0 to 5 are 8-bit i/o ports (that is in total 48 i/o lines) which may be used as general purpose ports and which provide alternate output functions dedicated to the on-chip peripherals of the sab 80(c)515. port 6 (an0 to an7) in the mymos versions, the analog input lines an0 to an7 can only be used as inputs for the a/d converter. in the acmcs versions these lines may also be used as digital inputs. in this case they are addressed as an additional input port (port 6) via special function register p6 (0db h ). since port 6 has no internal latch, the contents of sfr p6 only depends on the levels applied to the input lines. for details about this port please refer to section 7.1 (parallel i/o). peripheral control, data and status registers most of the special function registers are used as control, status, and data registers to handle the on-chip peripherals. in the special function register table the register names are organized in groups and each of these groups refer to one peripheral unit. more details on how to program these registers are given in the descriptions of the following peripheral units: unit symbol section ports C 7.1 serial channel C 7.2 timer 0/1 C 7.3 a/d-converter adc 7.4 timer 2 with comp/capt/reload ccu 7.5 power saving modes C 7.6 watchdog timer wdt 7.7 interrupt system C 8
semiconductor group 27 external bus interface 5 external bus interface the sab 80(c)515 allows for external memory expansion. to accomplish this, the external bus interface common to most 8051-based controllers is employed. 5.1 accessing external memory lt is possible to distinguish between accesses to external program memory and external data memory or other peripheral components respectively. this distinction is made by hardware: accesses to external program memory use the signal psen (program store enable) as a read strobe. accesses to external data memory use rd and wr to strobe the memory (alternate functions of p3.7 and p3.6, see section 7.1.). port 0 and port 2 (with exceptions) are used to provide data and address signals. in this section only the port 0 and port 2 functions relevant to external memory accesses are described (for further details see chapter 7.1). fetches from external program memory always use a 16-bit address. accesses to external data memory can use either a 16-bit address (movx @dptr) or an 8-bit address (movx @ri). role of p0 and p2 as data/address bus when used for accessing external memory, port 0 provides the data byte time-multiplexed with the low byte of the address. in this state, port 0 is disconnected from its own port latch, and the address/ data signal drives both fets in the port 0 output buffers. thus, in this application, the port 0 pins are not open-drain outputs and do not require external pullup resistors. during any access to external memory, the cpu writes 0ff h to the port 0 latch (the special function register), thus obliterating whatever information the port 0 sfr may have been holding. whenever a 16-bit address is used, the high byte of the address comes out on port 2, where it is held for the duration of the read or write cycle. during this time, the port 2 lines are disconnected from the port 2 latch (the special function register). thus the port 2 latch does not have to contain 1 s, and the contents of the port 2 sfr are not modified. lf an 8-bit address is used (movx @ri), the contents of the port 2 sfr remain at the port 2 pins throughout the external memory cycle. this will facilitate paging. lt should be noted that, if a port 2 pin outputs an address bit that is a 1, strong pullups will be used for the entire read/write cycle and not only for two oscillator periods.
semiconductor group 28 external bus interface timing the timing of the external bus interface, in particular the relationship between the control signals ale, psen , rd and information on port 0 and port 2, is illustrated in figure 5-1 a) and b) . data memory : in a write cycle, the data byte to be written appears on port 0 just before wr is activated, and remains there until after wr is deactivated. in a read cycle, the incoming byte is accepted at port 0 before the read strobe is deactivated. program memory : signal psen functions as a read strobe. for further information see section 5.2. external program memory access the external program memory is accessed under two conditions: C whenever signal ea is active; or C whenever the program counter (pc) contains a number that is larger than 01fff h . this requires the rom-less versions sab 80c535/80535 to have ea wired low to allow the lower 8 k program bytes to be fetched from external memory. when the cpu is executing out of external program memory, all 8 bits of port 2 are dedicated to an output function and may not be used for general-purpose i/o. the contents of the port 2 sfr however is not affected. during external program memory fetches port 2 lines output the high byte of the pc, and during accesses to external data memory they output either dph or the port 2 sfr (depending on whether the external data memory access is a movx @dptr or a movx @ri). since the sab 80c535/80535 has no internal program memory, accesses to program memory are always external, and port 2 is at all times dedicated to output the high-order address byte. this means that port 0 and port 2 of the sab 80c535/80535 can never be used as general-purpose i/o. this also applies to the sab 80c515/80515 when it is operated with only an external program memory.
semiconductor group 29 external bus interface 5.2 psen , program store enable the read strobe for external fetches is psen . psen is not activated for internal fetches. when the cpu is accessing external program memory, psen is activated twice every cycle (except during a movx instruction) no matter whether or not the byte fetched is actually needed for the current instruction. when psen is activated its timing is not the same as for rd . a complete rd cycle, including activation and deactivation of ale and rd , takes 12 oscillator periods. a complete psen cycle, including activation and deactivation of ale and psen takes 6 oscillator periods. the execution sequence for these two types of read cycles is shown in figure 5-1 a) and b) . 5.3 ale, address latch enable the main function of ale is to provide a properly timed signal to latch the low byte of an address from p0 into an external latch during fetches from external memory. the address byte is valid at the negative transition of ale. for that purpose, ale is activated twice every machine cycle. this activation takes place even it the cycle involves no external fetch. the only time no ale pulse comes out is during an access to external data memory when rd /wr signals are active. the first ale of the second cycle of a movx instruction is missing ( see figure 5-1b) ). consequently, in any system that does not use data memory, ale is activated at a constant rate of 1/6 of the oscillator frequency and can be used for external clocking or timing purposes. 5.4 overlapping external data and program memory spaces in some applications it is desirable to execute a program from the same physical memory that is used for storing data. in the sab 80(c)515, the external program and data memory spaces can be combined by and-ing psen and rd . a positive logic and of these two signals produces an active low read strobe that can be used for the combined physical memory. since the psen cycle is faster than the rd cycle, the external memory needs to be fast enough to adapt to the psen cycle.
semiconductor group 30 external bus interface figure 5-1 a) and b) external program memory execution
semiconductor group 31 system reset 6 system reset 6.1 hardware reset and power-up reset 6.1.1 reset function and circuitries the hardware reset function incorporated in the sab 80(c)515 allows for an easy automatic start- up at a minimum of additional hardware and forces the controller to a predefined default state. the hardware reset function can also be used during normal operation in order to restart the device. this is particularly done when the power-down mode (see section 7.6) is to be terminated. in addition to the hardware reset, which is applied externally to the sab 80(c)515, there is also the possibility of an internal hardware reset. this internal reset will be initiated by the watchdog timer (section 7.7). the reset input is an active low input at pin 10 (reset ). an internal schmitt trigger is used at the input for noise rejection. since the reset is synchronized internally, the reset pin must be held low for at least two machine cycles (24 oscillator periods) while the oscillator is running. with the oscillator running the internal reset is executed during the second machine cycle in which reset is low and is repeated every cycle until reset goes high again. during reset, pins ale and psen are configured as inputs and should not be stimulated externally. (an external stimulation at these lines during reset activates several test modes which are reserved for test purposes. this in turn may cause unpredictable output operations at several port pins). a pullup resistor is internally connected to v cc to allow a power-up reset with an external capacitor only. an automatic reset can be obtained when v cc is applied by connecting the reset pin to v ss via a capacitor as shown in figure 6-1 a) and c) . after v cc has been turned on the capacitor must hold the voltage level at the reset pin for a specified time below the upper threshold of the schmitt trigger to effect a complete reset. the time required is the oscillator start-up time plus 2 machine cycles, which, under normal conditions, must be at least 10 - 20 ms for a crystal oscillator. this requirement is usually met using a capacitor of 4.7 to 10 microfarad. the same considerations apply if the reset signal is generated externally ( figure 6-1 b) ). in each case it must be assured that the oscillator has started up properly and that at least two machine cycles have passed before the reset signal goes inactive.
semiconductor group 32 system reset figure 6-1 a) - c) reset circuitries a correct reset leaves the processor in a defined state. the program execution starts at location 0000 h . the default values of the special function registers (sfr) during and after reset are listed in table 6-1 . after reset is internally accomplished the contents of the port latches of port 0 to 5 is 0ff h . this leaves port 0 floating, since it is an open drain port when not used as data/address bus. all other i/o port lines (ports 1 through 5) output a one (1). in the mymos versions, the analog input lines an0 to an7 can only be used as inputs. in the acmos versions these lines may also be used as digital inputs. in this case they are addressed as an additional input port (port 6) via special function register p6 (0db h ) since port 6 has no internal latch, the contents of sfr p6 only depends on the levels applied to the input lines. for details about this port please refer to section 7.1 (parallel i/o). the contents of the internal ram of the sab 80(c)515 is not affected by a reset. after power-up the contents is undefined, while it remains unchanged during a reset if the power supply is not turned off.
semiconductor group 33 system reset table 6-1 register contents after reset register contents register contents p0 - p5 0ff h dptr 0000 h tcon 00 h tl0, th0 00 h tl2, th2 00 h ien0, ien1 00 h ircon 00 h ccl1, cch1 00 h ccl3, cch3 00 h t2con 00 h adcon 00x0 0000b dapr 00 h b00 h pc 0000 h sp 07 h pcon 000x 0000b tmod 00 h tl1, th1 00 h scon 00 h sbuf undefined ip0 x000 0000b ip1 xx00 0000b ccen 00 h ccl2, cch2 00 h crcl, crch 00 h psw 00 h addat 00 h acc 00 h watchdog 0000 h
semiconductor group 34 system reset 6.1.2 hardware reset timing this section describes the timing of the hardware reset signal. the input pin reset is sampled once during each machine cycle. this happens in state 5 phase 2. thus, the external reset signal is synchronized to the internal cpu timing. when the reset is found active (low level at pin 10) the internal reset procedure is started. lt needs two complete machine cycles to put the complete device to its correct reset state. i.e. all special function registers contain their default values, the port latches contain 1s etc. note that this reset procedure is not performed if there is no clock available at the device. the reset signal must be active for at least two machine cycles; after this time the sab 80(c)515 remains in its reset state as long as the signal is active. when the signal goes inactive this transition is recognized in the following state 5 phase 2 of the machine cycle. then the processor starts its address output (when configured for external rom) in the following state 5 phase 1. one phase later (state 5 phase 2) the first falling edge at pin ale occurs. figure 6-2 shows this timing for a configuration with ea = 0 (external program memory). thus, between the release of the reset signal and the first falling edge at ale there is a time period of at least one machine cycle but less than two machine cycles. figure 6-2 cpu timing after reset mct01879 s4 s5 s6 s1 s2 s3 s4 s5 s6 s1 s2 s3 s4 s5 s6 s1 s2 p1 p2 pcl out pcl out pch out pch out one machine cycle reset p0 p2 ale in inst.
semiconductor group 35 on-chip peripheral components 7 on-chip peripheral components this chapter gives detailed information about all on-chip peripherals of the sab 80(c)515 except for the integrated interrupt controller, which is described separately in chapter 8. sections 7.1 and 7.2 are associated with the general parallel and serial i/o facilities while the remaining sections describe the miscellaneous functions such as the timers, serial interface, a/d converter, power saving modes, watchdog timer, oscillator and clock circuitries, and system clock output. 7.1 parallel i/o 7.1.1 port structures digital i/o the sab 80(c)515 allows for digital i/o on 48 lines grouped into 6 bidirectional 8-bit ports. each port bit consists of a latch, an output driver and an input buffer. read and write accesses to the i/o ports p0 through p5 are performed via their corresponding special function registers p0 to p5. the output drivers of port 0 and 2 and the input buffers of port 0 are also used for accessing external memory. in this application, port 0 outputs the low byte of the external memory address, time- multiplexed with the byte being written or read. port 2 outputs the high byte of the external memory address when the address is 16 bits wide. otherwise, the port 2 pins continue emitting the p2 sfr contents (see also chapter 7.1.2 and chapter 5 for more details about the external bus interface). digital/analog input ports the analog input lines an0 to an7 of the mymos versions can only be used as analog inputs. in the acmos versions these lines may also be used as digital inputs. in this case they are addressed as an additional input port (port 6) via special function register p6 (0db h ). since port 6 has no internal latch, the contents of sfr p6 only depends on the levels applied to the input lines. when used as analog input the required analog channel is selected by a three-bit field in sfr adcon , as described in section 7.4. of course, it makes no sense to output a value to these input- only ports by writing to the sfr p6 or p8; this will have no effect.
semiconductor group 36 on-chip peripheral components lf a digital value is to be read, the voltage levels are to be held within the input voltage specifications ( v il / v ih ). since p6 is not a bit-addressable register, all input lines of p6 are read at the same time by byte instructions. nevertheless, it is possible to use port 6 simultaneously for analog and digital input. however, care must be taken that all bits of p6 are masked which have an undetermined value caused by their analog function . in order to guarantee a high-quality a/d conversion, digital input lines of port 6 should not toggle while a neighbouring port pin is executing an a/d conversion. this could produce crosstalk to the analog signal. 7.1.1.1 digital i/o port circuitry (mymos/acmos) figure 7-1 shows a functional diagram of a typical bit latch and i/o buffer, which is the core of each of the 6 i/o-ports. the bit latch (one bit in the ports sfr) is represented as a type-d flip-flop, which will clock in a value from the internal bus in response to a "write-to-latch" signal from the cpu. the q output of the flip-flop is placed on the internal bus in response to a "read-latch" signal from the cpu. the level of the port pin itself is placed on the internal bus in response to a "read-pin" signal from the cpu. some instructions that read from a port (i.e. from the corresponding port sfr p0 to p5) activate the "read-latch" signal, while others activate the "read-pin" signal (see section 7.1.4.3). figure 7-1 basic structure of a port circuitry
semiconductor group 37 on-chip peripheral components port 1 through 5 output drivers have internal pullup fets ( see figure 7-2 ). each i/o line can be used independently as an input or output. to be used as an input, the port bit must contain a one (1) (that means for figure 7-2 : q = 0), which turns off the output driver fet n1. then, for ports 1 through 5, the pin is pulled high by the internal pullups, but can be pulled low by an external source. when externally pulled low the port pins source current ( i il or i tl ). for this reason these ports are sometimes called "quasi-bidirectional". figure 7-2 basic output driver circuit of ports 1 through 5 in fact, the pullups mentioned before and included in figure 7-2 are pullup arrangements as shown in figure 7-3 . these pullup arrangements are realized differently in the mymos and acmos versions. in the next two sections both versions are discussed separately.
semiconductor group 38 on-chip peripheral components figure 7-3 output driver circuits of ports 1 through 5
semiconductor group 39 on-chip peripheral components 7.1.1.2 mymos port driver circuitry the output driver circuitry of the mymos version ( figure 7-3 ) consists of two pullup fets (pullup arrangements) and one pulldown fet: Cthe transistor n1 is a very strong pullup transistor which is only activated for two oscillator periods, if a 0-to-1 transition is executed by this port bit. transistor n1 is capable of driving high currents. Cthe transistor n2 is a weak pullup transistor, which is always switched on. when the pin is pulled down (e.g. when the port is used as input), it sources a low current. this value can be found as the parameter i il in the dc characteristics. C the transistor n3 is a very strong pull-down transistor which is switched on when a "0" is programmed to the corresponding port latch. transistor n3 is capable of sinking high currents ( i ol in the dc characteristics). a short circuit to v cc must be avoided if the transistor is turned on because the high current might destroy the fet. 7.1.1.3 acmos port driver circuitry the output driver circuitry of the acmos version ( figure 7-3 ) is realized by three pullup fets (pullup arrangement) and one pulldown fet: Cthe pulldown fet n1 is of n-channel type. lt is a very strong driver transistor which is capable of sinking high currents ( i ol ); it is only activated if a "0" is programmed to the port pin. a short circuit to v cc must be avoided if the transistor is turned on, since the high current might destroy the fet. Cthe pullup fet p1 is of p-channel type. lt is activated for two oscillator periods (s1p1 and s1p2) if a 0-to-1 transition is programmed to the port pin, i.e. a "1" is programmed to the port latch which contained a "0". the extra pullup can drive a similar current as the pulldown fet n1. this provides a fast transition of the logic levels at the pin. Cthe pullup fet p2 is of p-channel type. lt is always activated when a "1" is in the port latch, thus providing the logic high output level. this pullup fet sources a much lower current than p1; therefore the pin may also be tied to ground, e.g. when used as input with logic low input level. C the pullup fet p3 is of p-channel type. lt is only activated if the voltage at the port pin is higher than approximately 1.0 to 1.5 v. this provides an additional pullup current if a logic high level is to be output at the pin (and the voltage is not forced lower than approximately 1.0 to 1.5 v). however, this transistor is turned off if the pin is driven to a logic low level, e.g. when used as input. in this configuration only the weak pullup fet p2 is active, which sources the current i il . lf, in addition, the pullup fet p3 is activated, a higher current can be sourced ( i tl ). thus, an additional power consumption can be avoided if port pins are used as inputs with a low level applied. however, the driving cabability is stronger if a logic high level is output. the described activating and deactivating of the four different transistors translates into four states the pins can be: C input low state (il), p2 active only C input high state (ih) = steady output high state (soh) p2 and p3 active C forced output high state (foh), p1, p2 and p3 active C output low state (ol), n1 active
semiconductor group 40 on-chip peripheral components if a pin is used as input and a low level is applied, it will be in il state, if a high level is applied, it will switch to ih state. if the latch is loaded with "0", the pin will be in ol state. if the latch holds a "0" and is loaded with "1", the pin will enter foh state for two cycles and then switch to soh state. if the latch holds a "1" and is reloaded with a "1" no state change will occur. at the beginning of power-on reset the pins will be in il state (latch is set to "1", voltage level on pin is below of the trip point of p3). depending on the voltage level and load applied to the pin, it will remain in this state or will switch to ih (=soh) state. if it is used as output, the weak pull-up p2 will pull the voltage level at the pin above p3s trip point after some time and p3 will turn on and provide a strong "1". note, however, that if the load exceeds the drive capability of p2 ( i il ), the pin might remain in the il state and provide a week "1" until the first 0-to-1 transition on the latch occurs. until this the output level might stay below the trip point of the external circuitry. the same is true if a pin is used as bidirectional line and the external circuitry is switched from outpout to input when the pin is held at "0" and the load then exceeds the p2 drive capabilities. if the load exceeds i il the pin can be forced to "1" by writing a "0" followed by a "1" to the port pin. port 0, in contrast to ports 1 through 5, is considered as "true" bidirectional, because the port 0 pins float when configured as inputs. thus, this port differs in not having internal pullups. the pullup fet in the p0 output driver ( see figure 7-4 a) ) is used only when the port is emitting 1 s during the external memory accesses. otherwise, the pullup is always off. consequently, p0 lines that are used as output port lines are open drain lines. writing a "1" to the port latch leaves both output fets off and the pin floats. in that condition it can be used as high-impedance input. lf port 0 is configured as general i/o port and has to emit logic high level (1), external pullups are required. figure 7-4 a) port 0 circuitry
semiconductor group 41 on-chip peripheral components 7.1.2 port 0 and port 2 used as address/data bus as shown in figures 7-4 a) and 7-4 b) , the output drivers of ports 0 and 2 can be switched to an internal address or address/data bus for use in external memory accesses. in this application they cannot be used as general purpose i/o, even if not all address lines are used externally. the switching is done by an internal control signal dependent on the input level at the ea pin and/or the contents of the program counter. lf the ports are configured as an address/data bus, the port latches are disconnected from the driver circuit. during this time, the p2 sfr remains unchanged while the p0 sfr has 1s written to it. being an address/data bus, port 0 uses a pullup fet as shown in figure 7-4 a) . when a 16-bit address is used, port 2 uses the additional strong pullups p1 to emit 1s for the entire external memory cycle instead of the weak ones (p2 and p3) used during normal port activity. figure 7-4 b) port 2 circuitry
semiconductor group 42 on-chip peripheral components 7.1.3 alternate functions several pins of ports 1 and 3 are multifunctional. they are port pins and also serve to implement special features as listed in table 7-1 . table 7-1 port pin alternate function p1.0 p1.1 p1.2 p1.3 p1.4 p1.5 p1.6 p1.7 p3.0 p3.1 p3.2 p3.3 p3.4 p3.5 p3.6 p3.7 int3 /cc0 int4/cc1 int5/cc2 int6/cc3 int2 t2ex clkout t2 rxd txd int0 int1 t0 t1 wr rd ext. interrupt 3 input, compare 0 output, capture 0 input ext. interrupt 4 input, compare 1 output, capture 1 input ext. interrupt 5 input, compare 2 output, capture 2 input ext. interrupt 6 input, compare 3 output, capture 3 input ext. interrupt 2 input timer 2 external reload trigger input system clock output timer 2 external reload trigger input serial ports receiver data input (asynchronous) or data input/output (synchronous) serial ports transmitter data output (asynchronous) or clock output (synchronous) external interrupt 0 input, timer 0 gate control external interrupt 1 input, timer 1 gate control timer 0 external counter input timer 1 external counter input external data memory write strobe external data memory read strobe
semiconductor group 43 on-chip peripheral components figure 7-5 shows a functional diagram of a port latch with alternate function. to pass the alternate function to the output pin and vice versa, however, the gate between the latch and driver circuit must be open. thus, to use the alternate input or output functions, the corresponding bit latch in the port sfr has to contain a one (1); otherwise the pull-down fet is on and the port pin is stuck at 0. (this does not apply to ports 1.0 to 1.3 when operated in compare output mode; refer to section 7.5.2 for details). after reset all port latches contain ones (1). figure 7-5 port 1 and 3
semiconductor group 44 on-chip peripheral components 7.1.4 port handling 7.1.4.1 port timing when executing an instruction that changes the value of a port latch, the new value arrives at the latch during s6p2 of the final cycle of the instruction. however, port latches are only sampled by their output buffers during phase 1 of any clock period (during phase 2 the output buffer holds the value it noticed during the previous phase 1). consequently, the new value in the port latch will not appear at the output pin until the next phase 1, which will be at s1p1 of the next machine cycle. when an instruction reads a value from a port pin (e.g. mov a, p1) the port pin is actually sampled in state 5 phase 1 or phase 2 depending on port and alternate functions. figure 7-6 illustrates this port timing. lt must be noted that this mechanism of sampling once per machine cycle is also used if a port pin is to detect an "edge", e.g. when used as counter input. in this case an "edge" is detected when the sampled value differs from the value that was sampled the cycle before. therefore, there must be met certain requirements on the pulse length of signals in order to avoid signal "edges" not being detected. the minimum time period of high and low level is one machine cycle, which guarantees that this logic level is noticed by the port at least once. figure 7-6 port timing
semiconductor group 45 on-chip peripheral components 7.1.4.2 port loading and interfacing the output buffers of ports 1 through 5 can drive ttl inputs directly. the maximum port load which still guarantees correct logic output levels can belooked up in the dc characteristics in the data sheet of the sab 80(c)515. the corresponding parameters are v ol and v oh . the same applies to port 0 output buffers. they do, however, require external pullups to drive floating inputs, except when being used as the address/data bus. when used as inputs it must be noted that the ports 1 through 5 are not floating but have internal pullup transistors. the driving devices must be capable of sinking a sufficient current if a logic low level shall be applied to the port pin (the parameters i tl and i il in the dc characteristics specify these currents). port 0 as well as the input only ports 6 of the acmos versions have floating inputs when used for digital input. 7.1.4.3 read-modify-write feature of ports 0 through 5 some port-reading instructions read the latch and others read the pin ( see figure 7-1 ). the instructions reading the latch rather than the pin read a value, possibly change it, and then rewrite it to the latch. these are called "read-modify-write" instructions, which are listed in table 7-2 . lf the destination is a port or a port bit, these instructions read the latch rather than the pin. note that all other instructions which can be used to read a port, exclusively read the port pin. in any case, reading from latch or pin, resp., is performed by reading the sfr p0 to p5; for example, "mov a, p3" reads the value from port 3 pins, while "anl p4, #0aa h " reads from the latch, modifies the value and writes it back to the latch.
semiconductor group 46 on-chip peripheral components table 7-2 read-modify-write instructions lt is not obvious that the last three instructions in this list are read-modify-write instructions, but they are. the reason is that they read the port byte, all 8 bits, modify the addressed bit, then write the complete byte back to the latch. the reason why read-modify-write instructions are directed to the latch rather than the pin is to avoid a possible misinterpretation of the voltage level at the pin. for example, a port bit might be used to drive the base of a transistor. when a "1" is written to the bit, the transistor is turned on. lf the cpu then reads the same port bit at the pin rather than the latch, it will read the base voltage of the transistor (approx. 0.7 v, i.e. a logic low level !) and interpret it as "0". for example, when modifying a port bit by a setb or clr instruction, another bit in this port with the above mentioned configuration might be changed if the value read from the pin were written back to the latch. however, reading the latch rather than the pin will return the correct value of "1". instruction function anl logic and; e.g. anl p1, a orl logic or; e.g. orl p2, a xrl logic exclusive or; e.g. xrl p3, a jbc jump if bit is set and clear bit; e.g. jbc p1.1, label cpl complement bit; e.g. cpl p3.0 inc increment byte; e.g. inc p4 dec decrement byte; e.g. dec p5 djnz decrement and jump if not zero; e.g. djnz p3, label mov px.y, c move carry bit to bit y of port x clr px.y clear bit y of port x setb px.y set bit y of port x
semiconductor group 47 on-chip peripheral components 7.2 serial interfaces the serial port of the sab 80(c)515s enables communication between microcontrollers or between the microcontroller and peripheral devices. the serial port is full-duplex, meaning it can transmit and receive simultaneously. it is also receive buffered, meaning it can commence reception of a second byte before a previously received byte has been read from the receive register (however, if the first byte still has not been read by the time reception of the second byte is complete, the last received byte will be lost). the serial channel is completely compatible with the serial channel of the sab 80(c)51. 7.2.1 operating modes of serial interface the serial interface can operate in four modes (one synchronous mode, three asynchronous modes). the baud rate clock for this interface is derived from the oscillator frequency (mode 0, 2) or generated either by timer 1 or by a dedicated baud rate generator (mode 1, 3). a more detailed description of how to set the baud rate will follow in section 7.2.3. mode 0: shift register (synchronous) mode: serial data enters and exits through rxd. txd outputs the shift clock. 8 data bits are transmitted/ received (lsb first). the baud rate is fixed at 1/12 of the oscillator frequency. mode 1: 8-bit uart, variable baud rate: 10 bits are transmitted (through txd) or received (through rxd): a start bit (0), 8 data bits (lsb first), and a stop bit (1). on reception, the stop bit goes into rb8 in special function register scon. the baud rate is variable. mode 2: 9-bit uart, fixed baud rate: 11 bits are transmitted (through txd) or received (through rxd): a start bit (0), 8 data bits (lsb first), a programmable 9th bit, and a stop bit (1). on transmission, the 9th data bit (tb8 in scon) can be assigned to the value of 0 or 1. for example, the parity bit (p in the psw) could be moved into tb8 or a second stop bit by setting tb8 to 1. on reception the 9th data bit goes into rb8 in special function register scon, while the stop bit is ignored. the baud rate is programmable to either 1/32 or 1/64 of the oscillator frequency. mode 3: 9-bit uart, variable baud rate: 11 bits are transmitted (through txd) or received (through rxd): a start bit (0), 8 data bits (lsb first), a programmable 9th bit, and a stop bit (1). on transmission, the 9th data bit (tb8 in scon) can be assigned to the value of 0 or 1. for example, the parity bit (p in the psw) could be moved into tb8 or a second stop bit by setting tb8 to 1. on reception, the 9th data bit goes into rb8 in special function register scon, while the stop bit is ignored. in fact, mode 3 is the same as mode 2 in all respects except the baud rate. the baud rate in mode 3 is variable.
semiconductor group 48 on-chip peripheral components in all four modes, transmission is initiated by any instruction that uses sbuf as a destination register. reception is initiated in mode 0 by the condition ri = 0 and ren = 1. reception is initiated in the other modes by the incoming start bit if ren = 1. the serial interfaces also provide interrupt requests when a transmission or a reception of a frame has completed. the corresponding interrupt request flags for serial interface are ti or ri, resp. see section 8 for more details about the interrupt structure. the interrupt request flags ti and ri can also be used for polling the serial interface if the serial interrupt is not to be used (i.e. serial interrupt not enabled). the control and status bits of the serial channel 0 in special function register s0con are illustrated in figure 7-8 . figure 7-7 shows the special function register s0buf which is the data register for receive and transmit. the following table summarizes the operating modes of serial interface 0. figure 7-7 special function register scon (address 98 h ) bit symbol sm0 sm1 00 01 10 11 serial mode 0: shift register mode, fixed baud rate serial mode 1: 8-bit uart, variable baud rate serial mode 2: 9-bit uart, fixed baud rate serial mode 3: 9-bit uart, variable baud rate sm2 enables the multiprocessor communication feature in modes 2 and 3. in mode 2 or 3 and sm2 being set to 1, ri will not be activated if the received 9th data bit (rb8) is 0. in mode 1 and sm2 = 1, ri will not be activated if a valid stop bit has not been received. in mode 0, sm2 should be 0. ren receiver enable. enables serial reception. set by software to enable reception. cleared by software to disable reception. tb8 transmitter bit 8. is the 9th data bit that will be transmitted in modes 2 and 3. set or cleared by software as desired. rb8 receiver bit 8. in modes 2 and 3 it is the 9th bit that was received. in mode 1, if sm2 = 0, rb8 is the stop bit that was received. in mode 0, rb8 is not used. ti transmitter interrupt. is the transmit interrupt flag. set by hardware at the end of the 8th bit time in mode 0, or at the beginning of the stop bit in the other modes, in any serial transmission. must by cleared by software. ri receiver interrupt. is the receive interrupt flag. set by hardware at the end of the 8th bit time in mode 0, or during the stop bit time in the other modes, in any serial reception. must be cleared by software. sm0 sm1 sm2 ren tb8 rb8 ti ri 98 h scon 9f h 9e h 9d h 9c h 9b h 9a h 99 h 98 h
semiconductor group 49 on-chip peripheral components the control and status bits of the serial channel in special function register scon are illustrated in figure 7-8 . figure 7-7 shows the special function register sbuf which is the data register for receive and transmit. the following table summarizes the operating modes of the serial interface. table 7-3 serial interface, mode selection figure 7-8 special function register sbuf (address 99 h ) receive and transmit buffer of serial interface. writing to sbuf loads the transmit register and initiates transmission. reading out sbuf accesses a physically separate receive register. sm0 sm1 mode descriptions baud rate 0 0 0 shift register f osc /12 0 1 1 8-bit uart variable 1 0 2 9-bit uart f osc /64 or f osc /32 1 1 3 9-bit uart variable serial interface buffer register sbuf 99 h
semiconductor group 50 on-chip peripheral components 7.2.2 multiprocessor communication feature modes 2 and 3 of the serial interface 0 have a special provision for multi-processor communication. in these modes, 9 data bits are received. the 9th bit goes into rb8. then a stop bit follows. the port can be programmed such that when the stop bit is received, the serial port 0 interrupt will be activated (i.e. the request flag ri is set) only if rb8 = 1. this feature is enabled by setting bit sm2 in scon. a way to use this feature in multiprocessor communications is as follows. lf the master processor wants to transmit a block of data to one of the several slaves, it first sends out an address byte which identifies the target slave. an address byte differs from a data byte in that the 9th bit is 1 in an address byte and 0 in a data byte. with sm2 = 1, no slave will be interrupted by a data byte. an address byte, however, will interrupt all slaves, so that each slave can examine the received byte and see if it is being addressed. the addressed slave will clear its sm2 bit and prepare to receive the data bytes that will be coming. after having received a complete message, the slave sets sm2 again. the slaves that were not addressed leave their sm2 set and go on about their business, ignoring the incoming data bytes. sm2 has no effect in mode 0. in mode 1 sm2 can be used to check the validity of the stop bit. lf sm2 = 1 in mode 1, the receive interrupt will not be activated unless a valid stop bit is received. 7.2.3 baud rates as already mentioned there are several possibilities to generate the baud rate clock for the serial interface depending on the mode in which it is operated. to clarify the terminology, something should be said about the difference between "baud rate clock" and "baud rate". the serial interface requires a clock rate which is 16 times the baud rate for internal synchronization, as mentioned in the detailed description of the various operating modes in section 7.2.4. therefore, the baud rate generator have to provide a "baud rate clock" to the serial interface which - there divided by 16 - results in the actual "baud rate". however, all formulas given in the following section already include the factor and calculate the final baud rate.
semiconductor group 51 on-chip peripheral components mode 0 the baud rate in mode 0 is fixed: mode 2 the baud rate in mode 2 depends on the value of bit smod in special function register pcon ( see figure 7-9 ). if smod = 0 (which is the value after reset), the baud rate is 1/64 of the oscillator frequency. if smod = 1, the baud rate is 1/32 of the oscillator frequency. figure 7-9 special function register pcon (address 87 h ) modes 1 and 3 in these modes the baud rate is variable and can be generated alternatively by a dedicated baud rate generator or by timer 1. using the baud rate generator: in modes 1 and 3, the sab 80(c)515 can use the internal baud rate generator for the serial interface. to enable this feature, bit bd (bit 7 of special function register adcon) must be set ( see figure 7-10 ). this baud rate generator divides the oscillator frequency by 2500. bit smod (pcon.7) also can be used to enable a multiply by two prescaler ( see figure 7-9 ). at 12-mhz oscillator frequency, the commonly used baud rates 4800 baud (smod = 0) and 9600 baud (smod = 1) are available. the baud rate is determined by smod and the oscillator frequency as follows: bit function smod when set, the baud rate of serial interface in modes 1, 2, 3 is doubled. mode 0 baud rate = oscillator frequency 12 mode 2 baud rate = oscillator frequency 64 2 smod x smod pds idls C gf1 gf0 pde idle 87 h pcon these bits are not used in controlling serial interface. mode 1, 3 baud rate = oscillator frequency 2500 2 smod x
semiconductor group 52 on-chip peripheral components figure 7-10 special function register adcon (address 0d8 h ) using timer 1 to generate baud rates: timer 1 can be used for generating baud rates in mode 1 and 3 of the serial channel. then the baud rate is determined by the timer 1 overflow rate and the value of smod as follows: the timer 1 interrupt is usually disabled in this application. the timer itself can be configured for either "timer" or "counter" operation, and in any of its operating modes. in the most typical applications, it is configured for "timer" operation in the auto-reload mode (high nibble of tmod = 0010b). in the case, the baud rate is given by the formula: one can achieve very low baud rates with timer 1 by leaving the timer 1 interrupt enabled, configuring the timer to run as 16-bit timer (high nibble of tmod = 0001b), and using the timer 1 interrupt for a 16-bit software reload. table 7-4 lists various commonly used baud rates and shows how they can be obtained from timer 1. bit function bd baud rate enable. when set, the baud rate in modes 1 and 3 of serial interface is taken from a dedicated prescaler. standard baud rates 4800 and 9600 baud at 12-mhz oscillator frequency can be achieved. bd clk adex bsy adm mx2 mx1 mx0 0d8 h adcon these bits are not used in controlling serial interface. 0df h 0de h 0dd h 0dc h 0db h 0da h 0d9 h 0d8 h mode 1, 3 baud rate = (timer 1 ov-rate) 32 2 smod x mode 1, 3 baud rate = 32 x 12 x (256 C (th1)) 2 smod x oscillator frequency
semiconductor group 53 on-chip peripheral components table 7-4 timer 1 generated commonly used baud rates figure 7-11 shows the mechanisms for baud rate generation of serial channel, while table 7-5 summarizes the baud rate formulas for all usual configurations. figure 7-11 generation of baud rates for serial interface baud rate f osc (mhz) smod timer 1 c/t mode reload value mode 1, 3: 62.5 kbaud 19.5 kbaud 9.6 kbaud 4.8 kbaud 2.4 kbaud 1.2 kbaud 110 baud 110 baud 12.0 11.059 11.059 11.059 11.059 11.059 6.0 12.0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2 2 2 2 2 2 1 ff h fd h fd h fa h f4 h e8 h 72 h feeb h
semiconductor group 54 on-chip peripheral components table 7-5 baud rates of serial interface 0 7.2.4 detailed description of the operating modes the following sections give a more detailed description of the several operating modes of the serial interface. 7.2.4.1 mode 0, synchronous mode serial data enters and exits through rxd. txd outputs the shift clock. 8 bits are transmitted/ received: 8 data bits (lsb first). the baud rate is fixed at 1/12 of the oscillator frequency. figures 7-16 a) and b) show a simplified functional diagram of the serial port in mode 0, and associated timing. transmission is initiated by any instruction that uses sbuf as a destination register. the "write-to- sbuf" signal at s6p2 also loads a 1 into the 9th bit position of the transmit shift register and tells the tx control block to commence a transmission. the internal timing is such that one full machine cycle will elapse between "write-to-sbuf" and activation of send. baud rate derived from interface mode baud rate timer 1 in mode 1 1, 3 timer 1 in mode 2 1, 3 oscillator 2 baud rate generator 1, 3 x (timer 1 overflow rate) 2 smod 1 16 x 2 2 smod 1 16 x 2 x f osc 12 x (256 C (th1)) 2 smod 1 16 x 2 x f osc 2 2 smod 1 16 x 2 x f osc 1250
semiconductor group 55 on-chip peripheral components send enables the output of the shift register to the alternate output function line p3.0, and also enables shift clock to the alternate output function line p3.1. shift clock is low during s3, s4, and s5 of every machine cycle, and high during s6, s1, and s2, while the interface is transmitting. before and after transmission shift clock remains high. at s6p2 of every machine cycle in which send is active, the contents of the transmit shift register is shifted one position to the right. as data bits shift to the right, zeros come in from the left. when the msb of the data byte is at the output position of the shift register, then the 1 that was initially loaded into the 9th position, is just left of the msb, and all positions to the left of that contain zeros. this condition flags the tx control block to do one last shift and then deactivates send and sets ti. both of these actions occur at s1p1 in the 10th machine cycle after "write-to-sbuf". reception is initiated by the condition ren = 1 and ri = 0. at s6p2 in the next machine cycle, the rx control unit writes the bits 1111 1110 to the receive shift register, and in the next clock phase activates receive. receive enables shift clock to the alternate output function line of p3.1. shift clock makes transitions at s3p1 and s6p1 in every machine cycle. at s6p2 of every machine cycle in which receive is active, the contents of the receive shift register are shifted one position to the left. the value that comes in from the right is the value that was sampled at the p3.0 pin at s5p2 in the same machine cycle. as data bits come in from the right, 1 s shift out to the left. when the 0 that was initially loaded into the rightmost position arrives at the leftmost position in the shift register, it flags the rx control block to do one last shift and load sbuf. at s1p1 in the 10th machine cycle after the write to scon that cleared ri, receive is cleared and ri is set. 7.2.4.2 mode 1, 8-bit uart ten bits are transmitted (through txd), or received (through rxd): a start bit (0), 8 data bits (lsb first), and a stop bit (1). on reception through rxd, the stop bit goes into rb8 (scon). the baud rate for serial interface 0 is determined by the timer 1 overflow rate or by the internal baud rate generator. figures 7-17 a) and b) show a simplified functional diagram of the serial channel in mode 1. the generation of the baud rate clock is described in section 7.2.3.
semiconductor group 56 on-chip peripheral components transmission is initiated by any instruction that uses sbuf as a destination register. the "write-to- sbuf" signal also loads a 1 into the 9th bit position of the transmit shift register and flags the tx control block that a transmission is requested. transmission actually commences at s1p1 of the machine cycle following the next roll-over in the divide-by-16 counter (thus, the bit times are synchronized to the divide-by-16 counter, not to the "write-to-sbuf" signal). the transmission begins with activation of send , which puts the start bit to txd. one bit time later, data is activated, which enables the output bit of the transmit shift register to txd. the first shift pulse occurs one bit time after that. as data bits shift out to the right, zeros are clocked in from the left. when the msb of the data byte is at the output position of the shift register, then the 1 that was initially loaded into the 9th position, is just left of the msb, and all positions to the left of that contain zero. this condition flags the tx control to do one last shift and then deactivates send and sets ti. this occurs at the 10th divide- by-16 rollover after "write-to-sbuf". reception is initiated by a detected 1-to-0 transition at rxd. for this purpose rxd is sampled at a rate of 16 times whatever baud rate has been established. when a reception is detected, the divide- by-16 counter is immediately reset, and 1ff h is written into the input shift register. resetting the divide-by-16 counter aligns its rollover with the boundaries of the incoming bit times. the 16 states of the counter divide each bit time into 16 counter states. at the 7th, 8th and 9th counter state of each bit time, the bit detector samples the value of rxd. the value accepted is the value that was seen in at least 2 of the 3 samples. this is done for noise rejection. lf the value accepted during the first bit time is not 0, the receive circuits are reset and the unit goes back looking for another 1-to-0 transition. this is to provide rejection of false start bits. lf the start bit proves valid, it is shifted into the input shift register, and reception of the rest of the frame will proceed. as data bits come from the right, 1s shift out to the left. when the start bit arrives at the leftmost position in the shift register (which in mode 1 is a 9-bit register), it flags the rx control block to do one last shift. the signal to load sbuf and rb8 and to set ri will be generated if, and only if, the following conditions are met at the time the final shift pulse is generated: 1) ri = 0, and 2) either sm2 = 0 or the received stop bit = 1 lf either of these two conditions is not met the received frame is irretrievably lost. lf both conditions are met, the stop bit goes into rb8, the 8 data bits go into sbuf, and ri is activated. at this time, no matter whether the above conditions are met or not, the unit goes back to looking for a 1-to-0 transition in rxd.
semiconductor group 57 on-chip peripheral components 7.2.4.3 mode 2, 9-bit uart mode 2 is functionally identical to mode 3 (see below). the only exception is, that in mode 2 the baud rate can be programmed to two fixed quantities: either 1/32 or 1/64 of the oscillator frequency. in mode 3 the baud rate clock is generated by timer 1, which is incremented by a rate of f osc /12 or by the internal baud rate generator. 7.2.4.4 mode 3, 9-bit uart eleven bits are transmitted (through txd), or received (through rxd): a start bit (0), 8 data bits (lsb first), a programmable 9th data bit, and a stop bit (1). on transmission, the 9th data bit (tb8) can be assigned the value of 0 or 1. on reception the 9th data bit goes into rb8 in scon. the baud rate is generated by either using timer 1 or the internal baud rate generator (see section 7.2.3). figures 7-18 a) and b) show a functional diagram of the serial interfaces in mode 2 and 3 and associated timing. the receive portion is exactly the same as in mode 1. the transmit portion differs from mode 1 only in the 9th bit of the transmit shift register. transmission is initiated by any instruction that uses sbuf as a destination register. the "write to sbuf" signal also loads tb8 into the 9th bit position of the transmit shift register and flags the tx control unit that a transmission is requested. transmission commences at s1p1 of the machine cycle following the next rollover in the divide-by-16 counter (thus the bit times are synchronized to the divide-by-16 counter, and not to the "write-to-sbuf" signal). the transmission begins with the activation of send , which puts the start bit to txd. one bit time later, data is activated which enables the output bit of transmit shift register to txd. the first shift pulse occurs one bit time after that. the first shift clocks a 1 (the stop bit) into the 9th bit position of the shift register. thereafter, only zeros are clocked in. thus, as data shift out to the right, zeros are clocked in from the left. when tb8 is at the output position of the shift register, then the stop bit is just left of the tb8, and all positions to the left of that contain zeros. this condition flags the tx control unit to do one last shift and then deactivate send and set ti. this occurs at the 11th divide-by-16 rollover after "write-to-sbuf". reception is initiated by a detected 1-to-0 transition at rxd. for this purpose rxd is sampled of a rate of 16 times whatever baud rate has been established. when a transition is detected, the divide- by-16 counter is immediately reset, and 1f h is written to the input shift register.
semiconductor group 58 on-chip peripheral components at the 7th, 8th and 9th counter state of each bit time, the bit detector samples the value of rxd. the value accepted is the value that was seen in at least 2 of the 3 samples. lf the value accepted during the first bit time is not 0, the receive circuits are reset and the unit goes back to looking for another 1-to-0 transition. lf the start bit proves valid, it is shifted into the input shift register, and reception of the rest of the frame will proceed. as data bits come from the right, 1 s shift out to the left. when the start bit arrives at the leftmost position in the shift register (which is a 9-bit register), it flags the rx control block to do one last shift, load sbuf and rb8, and set ri. the signal to load sbuf and rb8, and to set ri, will be generated if, and only if, the following conditions are met at the time the final shift pulse is generated: 1) ri = 0, and 2) either sm2 = 0 or the received 9th data bit = 1 lf either one of these two conditions is not met, the received frame is irretrievably lost, and ri is not set. lf both conditions are met, the received 9th data bit goes into rb8, the first 8 data bits go into sbuf. one bit time later, no matter whether the above conditions are met or not, the unit goes back to look for a 1-to-0 transition at the rxd. note that the value of the received stop bit is irrelevant to sbuf, rb8, or ri.
semiconductor group 59 on-chip peripheral components figure 7-16 a) functional diagram - serial interface, mode 0
semiconductor group 60 on-chip peripheral components figure 7-16 b) timing diagram - serial interface, mode 0
semiconductor group 61 on-chip peripheral components figure 7-17 a) functional diagram - serial interface, mode 1
semiconductor group 62 on-chip peripheral components figure 7-17 b) timing diagram - serial interface, mode 1
semiconductor group 63 on-chip peripheral components figure 7-18 a) functional diagram - serial interface, modes 2 and 3
semiconductor group 64 on-chip peripheral components figure 7-18 b) timing diagram - serial interface, modes 2 and 3
semiconductor group 65 on-chip peripheral components 7.3 timer 0 and timer 1 the sab 80(c)515 three general purpose 16-bit timer/counters: timer 0, timer 1, timer 2 and the compare timer (timer 2 is discussed separately in section 7.5). timer/counter 0 and 1 are fully compatible with timer/counters 0 and 1 of the sab 80(c)51 and can be used in the same operating modes. timer/counter 0 and 1 which are discussed in this section can be configured to operate either as timers or event counters: C in "timer" function, the register is incremented every machine cycle. thus one can think of it as counting machine cycles. since a machine cycle consists of 12 oscillator periods, the count rate is 1/12 of the oscillator frequency. C in "counter" function, the register is incremented in response to a 1-to-0 transition (falling edge) at its corresponding external input pin, t0 or t1 (alternate functions of p3.4 and p3.5, resp.). in this function the external input is sampled during s5p2 of every machine cycle. when the samples show a high in one cycle and a low in the next cycle, the count is incremented. the new count value appears in the register during s3p1 of the cycle following the one in which the transition was detected. since it takes two machine cycles (24 oscillator periods) to recognize a 1-to-0 transition, the maximum count rate is 1/24 of the oscillator frequency. there are no restrictions on the duty cycle of the external input signal, but to ensure that a given level is sampled at least once before it changes, it must be held for at least one full machine cycle. in addition to the "timer" and "counter" selection, timer/counters 0 and 1 have four operating modes from which to select.
semiconductor group 66 on-chip peripheral components figure 7-19 special function register tcon (address 88 h ) each timer consists of two 8-bit registers (th0 and tl0 for timer/counter 0, th1 and tl1 for timer/ counter 1) which may be combined to one timer configuration depending on the mode that is established. the functions of the timers are controlled by two special function registers tcon and tmod, shown in figures 7-19 and 7-20 . in the following descriptions the symbols th0 and tl0 are used specify the high-byte and low-byte of timer 0 (th1 and tl1 for timer 1, respectively). the operating modes are described and shown for timer 0. if not explicitly noted, this applies also to timer 1. bit function tr0 timer 0 run control bit. set/cleared by software to turn timer/counter 0 on/off. tf0 timer 0 overflow flag. set by hardware on timer/counter overflow. cleared by hardware when processor vectors to interrupt routine. tr1 timer 1 run control bit. set/cleared by software to turn timer/counter 1 on/off. tf1 timer 1 overflow flag. set by hardware on timer/counter overflow. cleared by hardware when processor vectors to interrupt routine. these bits are not used in controlling timer/counter 0 and 1. 8f h 8e h 8d h 8c h 8b h 8a h 89 h 88 h tf1 tr1 tf0 tr0 ie1 it1 ie0 it0 88 h tcon
semiconductor group 67 on-chip peripheral components figure 7-20 special function register tmod (address 89 h ) timer/counter 0/1 mode control register. bit symbol gate gating control. when set, timer/counter "x" is enabled only while "intx " pin is high and "trx" control bit is set. when cleared timer "x" is enabled whenever "trx" control bit is set. c/t counter or timer select bit. set for counter operation (input from "tx" input pin). cleared for timer operation (input from internal system clock). m1 m0 0 0 8-bit timer/counter "thx" operates as 8-bit timer/counter "tlx" serves as 5-bit prescaler. 0 1 16-bit timer/counter. "thx" and "tlx" are cascaded; there is no prescaler. 1 0 8-bit auto-reload timer/counter. "thx" holds a value which is to be reloaded into "tlx" each time it overflows. 11timer 0: tl0 is an 8-bit timer/counter controlled by the standard timer 0 control bits. th00 is an 8-bit timer only controlled by timer 1 control bits. 11timer 1: timer/counter 1 stops gate c/t m1 m0 gate c/t m1 m0 89 h tmod timer 1 timer 0
semiconductor group 68 on-chip peripheral components 7.3.1 mode 0 putting either timer/counter into mode 0 configures it as an 8-bit timer/counter with a divide-by-32 prescaler. figure 7-21 shows the mode 0 operation. in this mode, the timer register is configured as a 13-bit register. as the count rolls over from all 1s to all 0s, it sets the timer overflow flag tf0. the overflow flag tf0 then can be used to request an interrupt (see section 8 for details about the interrupt structure). the counted input is enabled to the timer when tr0 = 1 and either gate = 0 or int0 = 1 (setting gate = 1 allows the timer to be controlled by external input int0 , to facilitate pulse width measurements). tr0 is a control bit in the special function register tcon; gate is in tmod. the 13-bit register consists of all 8 bits of th1 and the lower 5 bits of tl0. the upper 3 bits of tl0 are indeterminate and should be ignored. setting the run flag (tr0) does not clear the registers. mode 0 operation is the same for timer 0 as for timer 1. substitute tr1, tf1, th1, tl1, and int1 for the corresponding timer 1 signals in figure 7-21 . there are two different gate bits, one for timer 1 (tmod.7) and one for timer 0 (tmod.3). figure 7-21 timer/counter 0, mode 0: 13 bit-timer/counter the same applies to timer/counter 1
semiconductor group 69 on-chip peripheral components 7.3.2 mode 1 mode 1 is the same as mode 0, except that the timer register is run with all 16 bits. mode 1 is shown in figure 7-22 . figure 7-22 timer/counter 0, mode 1: 16-bit timer/counter the same applies to timer/counter 1
semiconductor group 70 on-chip peripheral components 7.3.3 mode 2 mode 2 configures the timer register as an 8-bit counter (tl0) with automatic reload, as shown in figure 7-23 . overflow from tl0 not only sets tf0, but also reloads tl0 with the contents of th0, which is preset by software. the reload leaves th0 unchanged. figure 7-23 timer/counter 0, mode 2: 8-bit timer/counter with auto-reload the same applies to timer/counter 1
semiconductor group 71 on-chip peripheral components 7.3.4 mode 3 mode 3 has different effects on timer 0 and timer 1. timer 1 in mode 3 simply holds its count. the effect is the same as setting tr1 = 0. timer 0 in mode 3 establishes tl0 and th0 as two separate counters. the logic for mode 3 on timer 0 is shown in figure 7-24 . tl0 uses the timer 0 control bits: c/t , gate, tr0, int0 , and tf0. th0 is locked into a timer function (counting machine cycles) and takes over the use of tr1 and tf1 from timer 1. thus, th0 now controls the "timer 1" interrupt. mode 3 is provided for applications requiring an extra 8-bit timer or counter. when timer 0 is in mode 3, timer 1 can be turned on and off by switching it out of and into its own mode 3, or can still be used by the serial channel as a baud rate generator, or in fact, in any application not requiring an interrupt from timer 1 itself. figure 7-24 timer/counter 0, mode 3: two 8-bit timers/counters
semiconductor group 72 on-chip peripheral components 7.4 a/d converter the sab 80(c)515 provides an a/d converter with the following features: C eight multiplexed input channels C the possibility of using the analog input channels (port 6) as digital inputs (acmos version only). C programmable internal reference voltages (16 steps each) via resistor array C 8-bit resolution within the selected reference voltage range C 13 machine cycles conversion time for acmos versions (including sample time) C 15 machine cycles conversion time for mymos versions (including sample time) C internal start-of-conversion trigger C interrupt request generation after each conversion for the conversion, the method of successive approximation via capacitor array is used. the externally applied reference voltage range has to be held on a fixed value within the specifications (see section "a/d converter characteristics" in the data sheet). the internal reference voltages can be varied to reduce the reference voltage range of the a/d converter and thus to achieve a higher resolution. figure 7-25 shows a block diagram of the a/d converter. there are three user-accessible special function registers: adcon (a/d converter control register), addat (a/d converter data register) and dapr (d/a converter program register) for the programmable reference voltages.
semiconductor group 73 on-chip peripheral components figure 7-25 a/d converter block diagram
semiconductor group 74 on-chip peripheral components 7.4.1 function and control 7.4.1.1 lnitialization and input channel selection special function register adcon which is illustrated in figure 7-26 is used to set the operating modes, to check the status, and to select one of eight analog input channels. figure 7-26 special function register adcon (address 0d8 h ) register adcon contains two mode bits. bit adm is used to choose the single or continuous conversion mode. in single conversion mode only one conversion is performed after starting, while in continuous conversion mode after the first start a new conversion is automatically started on completion of the previous one. the busy flag bsy (adcon.4) is automatically set when a conversion is in progress. after completion of the conversion it is reset by hardware. this flag can be read only, a write has no effect. there is also an interrupt request flag iadc (ircon.0) that is set when a conversion is completed. see section 8 for more details about the interrupt structure. bit function mx0 mx1 mx2 select 8 input channels of the a/d converter, see table 7-6 adm a/d conversion mode. when set, a continuous conversion is selected. if adm = 0, the converter stops after one conversion. bsy busy flag. this flag indicates whether a conversion is in progress (bsy = 1). the flag is cleared by hardware when the conversion is completed. these bits are not used in controlling a/d converter functions. 0df h 0de h 0dd h 0dc h 0db h 0da h 0d9 h 0d8 h bd clk C bsy adm mx2 mx1 mx0 0d8 h adcon
semiconductor group 75 on-chip peripheral components table 7-6 selection of the analog input channels the bits mx0 to mx2 in special function register adcon are used for selection of the analog input channels. port 6 of the acmos versions is a dual purpose input port. lf the input voltage meets the specified logic levels, it can be used as digital input as well regardless of whether the pin levels are sampled by the a/d converter at the same time. the special function register addat ( figure 7-28 ) holds the converted digital 8-bit data result. the data remains in addat until it is overwritten by the next converted data. addat can be read or written under software control. lf the a/d converter of the sab 80(c)515 is not used, register addat can be used as an additional general purpose register. figure 7-28 special function register addat (address 0d9 h ) this register contains the 8-bit conversion result. 7.4.1.2 start of conversion an internal start of conversion is triggered by a write-to-dapr instruction. the start procedure itself is independent of the value which is written to dapr. however, the value in dapr determines which internal reference voltages are used for the conversion (see section 7.4.2). when single conversion mode is selected (adm = 0) only one conversion is performed. in continuous mode after completion of a conversion a new conversion is triggered automatically, until bit adm is reset. mx2 mx1 mx0 selected channel pin mymos acmos 0 0 0 analog input 0 an0 p6.0 0 0 1 analog input 1 an1 p6.1 0 1 0 analog input 2 an2 p6.2 0 1 1 analog input 3 an3 p6.3 1 0 0 analog input 4 an4 p6.4 1 0 1 analog input 5 an5 p6.5 1 1 0 analog input 6 an6 p6.6 1 1 1 analog input 7 an7 p6.7 conversion result addat 0d9 h
semiconductor group 76 on-chip peripheral components 7.4.2 reference voltages the sab 80(c)515 has two pins to which a reference voltage range for the on-chip a/d converter is applied (pin v aref for the upper voltage and pin v agnd for the lower voltage). in contrast to conventional a/d converters it is now possible to use not only these externally applied reference voltages for the conversion but also internally generated reference voltages which are derived from the externally applied ones. for this purpose a resistor ladder provides 16 equidistant voltage levels between v aref and v agnd . these steps can individually be assigned as upper and lower reference voltage for the converter itself. these internally generated reference voltages are called v lntaref and v lntagnd . the internal reference voltage programming can be thought of as a programmable "d/a converter" which provides the voltages v intarff and v intagnd for the a/d converter itself. the sfr dapr ( see figure 7-29 ) is provided for programming the internal reference voltages v intaref and v lntagnd . for this purpose the internal reference voltages can be programmed in steps of 1/16 of the external reference voltages ( v aref C v agnd ) by four bits each in register dapr. bits 0 to 3 specify v lntagnd , while bits 4 to 7 specify v intaref . a minimum of 1 v difference is required between the internal reference voltages v lntarf and v intagnd for proper operation of the a/d converter. this means, for example, in the case where v aref is 5 v and v agnd is 0 v, there must be at least four steps difference between the internal reference voltages v intaref and v intagnd . the values of v intagnd and v intaref are given by the formulas: dapr (.3-.0) is the contents of the low-order nibble, and dapr (.7-.4) the contents of the high-order nibble of dapr. v intagnd = v agnd + dapr (.3-.0) 16 ( v aref C v agnd ) with dapr (.3-.0) < c h ; v intaref = v agnd + dapr (.7-.4) 16 ( v aref C v agnd ) with dapr (.7-.4) > 3 h ;
semiconductor group 77 on-chip peripheral components if dapr (.3-.0) or dapr (.7-.4) = 0, the internal reference voltages correspond to the external reference voltages v agnd and v aref , respectively. if v ainput > v intaref , the conversion result is 0ff h , if v ainput < v intagdn , the conversion result is 00 h ( v ainput is the analog input voltage). if the external reference voltages v agnd = 0 v and v aref = +5 v (with respect to v ss and v cc ) are applied, then the following internal reference voltages v intagnd and v intaref shown in table 7-7 can be adjusted via the special function register dapr. figure 7-29 special function register dapr (address da h ) d/a converter program register. each 4-bit nibble is used to program the internal reference voltages. write-access to dapr starts conversion. dapr 0da h programming of v intaref programming of v intagnd v intagnd = v agnd + dapr (.3-.0) 16 ( v aref C v agnd ) with dapr (.3-.0) < 13; v intagnd = v agnd + dapr (.7-.4) 16 ( v aref C v agnd ) with dapr (.7-.4) > 3;
semiconductor group 78 on-chip peripheral components table 7-7 adjustable internal reference voltages the programmability of the internal reference voltages allows adjusting the internal voltage range to the range of the external analog input voltage or it may be used to increase the resolution of the converted analog input voltage by starting a second conversion with a compressed internal reference voltage range close to the previously measured analog value. figures 7-30 and 7-31 illustrate these applications. step dapr (.3-.0) dapr (.7-.4) v intagnd v intaref 0 0000 0.0 5.0 1 0001 0.3125 C 2 0010 0.625 C 3 0011 0.9375 C 4 0100 1.25 1.25 5 0101 1.5625 1.5625 6 0110 1.875 1.875 7 0111 2.1875 2.1875 8 1000 2.5 2.5 9 1001 2.8125 2.8125 10 1010 3.125 3.125 11 1011 3.4375 3.4375 12 1100 3.75 3.75 13 1101 C 4.0625 14 1110 C 4.375 15 1111 C 4.68754
semiconductor group 79 on-chip peripheral components figure 7-30 adjusting the internal reference voltages within range of the external analog input voltages figure 7-31 increasing the resolution by a second conversion
semiconductor group 80 on-chip peripheral components the external reference voltage supply need only be applied when the a/d converter is used, otherwise the pins v aref and v agnd may be left unconnected. the reference voltage supply has to meet some requirements concerning the level of v agnd and v aref and the output impedance of the supply voltage (see also "a/d converter characteristics" in the data sheet). C the voltage v aref must meet the following specification: v aref = v cc 5 % C the voltage v agnd must meet a similar specification: v agnd = v ss 0.2 v C the differential output impedance of the analog reference supply voltage should be less than 1 k w lf the above mentioned operating conditions are not met the accuracy of the converter may be decreased. furthermore, the analog input voltage v ainput must not exceed the range from ( v agnd C 0.2 v) to ( v aref + 0.2 v). otherwise, a static input current might result at the corresponding analog input which will also affect the accuracy of the other input channels. 7.4.3 a/d converter timing a conversion is started by writing into special function register dapr. a write-to-dapr will start a new conversion even if a conversion is currently in progress. the conversion begins with the next machine cycle and the busy flag bsy will be set. the conversion procedure is divided into three parts: load time ( t l ): during this time the analog input capacitance c i (see data sheet) must be loaded to the analog input voltage level. the external analog source needs to be strong enough to source the current to load the analog input capacitance during the load time. this causes some restrictions for the impedance of the analog source. for a typical application the value of the impedance should be less than approx. 5 k w . sample time ( t s ): during this time the internal capacitor array is connected to the selected analog input channel. the sample time includes the load time which is described above. after the load time has passed the selected analog input must be held constant for the rest of the sample time. otherwise the internal calibration of the comparator circuitry could be affected which might result in a reduced accuracy of the converter. however, in typical applications a voltage change of approx. 200 - 300 mv at the inputs during this time has no effect.
semiconductor group 81 on-chip peripheral components conversion time ( t c ): the conversion time t c includes the sample and load time. thus, t c is the total time required for one conversion. after the load time and sample time have elapsed, the conversion itself is performed during the rest of t c . in the last machine cycle the converted result is moved to addat; the busy flag (bsy) is cleared before. the a/d converter interrupt is generated by bit iadc in register ircon. iadc is already set some cycles before the result is written to addat. the flag iadc is set before the result is available in addat because the shortest possible interrupt latency time is taken into account in order to ensure optimal performance. thus, the converted result appears at the same time in addat when the first instruction of the interrupt service routine is executed. similar considerations apply to the timing of the flag bsy where usually a "jb bsy,$" instruction is used for polling. lf a continuous conversion is established, the next conversion is automatically started in the machine cycle following the last cycle of the previous conversion. figure 7-32 timing diagram of an a/d converter
semiconductor group 82 on-chip peripheral components 7.5 timer 2 with additional compare/capture/reload the timer 2 with additional compare/capture/reload features is one of the most powerful peripheral units of the sab 80(c)515. lt is used for all kinds of digital signal generation and event capturing like pulse generation, pulse width modulation, pulse width measuring etc. this allows various automotive control applications (ignition/injection-control, anti-lock-brake ? ) as well as industrial applications (dc-, three-phase ac- and stepper-motor control, frequency generation, digital-to-analog conversion, process control ?). please note that this timer is not equivalent to timer 2 of the sab 80(c)52 (see section 7.5.1 ). timer 2 in combination with the compare/capture/reload registers allows the following modes: compare: up to 4 pwm signals with 65535 steps at maximum, and 1 m sec resolution capture: up to 4 high speed inputs with 1 m sec resolution reload: modulation of timer 2 cycle time the block diagram in figure 7-33 a) shows the general configuration of timer 2 with the additional compare/capture/reload registers. the corresponding port functions are listed in table 7-8 . table 7-9 shows the additional special function registers of timer 2.
semiconductor group 83 on-chip peripheral components figure 7-33 a) timer 2 block diagram
semiconductor group 84 on-chip peripheral components figure 7-33 b) timer 2 in reload mode table 7-8 alternate port functions of timer 2 pin symbol input (i) output (o) function p1.7/t2 i/o external count or gate input to timer 2 p1.5/t2ex i/o external reload trigger input p1.3/int6/cc3 i/o comp. output/capture input for cc register 3 p1.2/int5/cc2 i/o comp. output/capture input for cc register 2 p1.1/int4/cc1 i/o comp. output/capture input for cc register 1 p1.0/int3 /cc0 i/o comp. output/capture input for crc register
semiconductor group 85 on-chip peripheral components table 7-9 additional special function registers of timer 2 7.5.1 timer 2 the timer 2, which is a 16-bit-wide register, can operate as timer, event counter, or gated timer. timer mode in timer function, the count rate is derived from the oscillator frequency. a 2:1 prescaler offers the possibility of selecting a count rate of 1/12 or 1/24 of the oscillator frequency. thus, the 16-bit timer register (consisting of th2 and tl2) is either incremented in every machine cycle or in every second machine cycle. the prescaler is selected by bit t2ps in special function register t2con ( see figure 7-35 ). lf t2ps is cleared, the input frequency is 1/12 of the oscillator frequency; if t2ps is set, the 2:1 prescaler gates 1/24 of the oscillator frequency to the timer. gated timer mode in gated timer function, the external input pin t2 (p1.7) functions as a gate to the input of timer 2. lf t2 is high, the internal clock input is gated to the timer. t2 = 0 stops the counting procedure. this will facilitate pulse width measurements. the external gate signal is sampled once every machine cycle (for the exact port timing, please refer to section 7.1 "parallel i/o"). symbol description address ccen cch1 cch2 cch3 ccl1 ccl2 ccl3 crch crcl ircon th2 tl2 t2con comp./capture enable reg. comp./capture reg. 1, high byte comp./capture reg. 2, high byte comp./capture reg. 3, high byte comp./capture reg. 1, low byte comp./capture reg. 2, low byte comp./capture reg. 3, low byte com./rel./capt. reg., high byte com./rel./capt. reg., low byte interrupt control register timer 2, high byte timer 2, low byte timer 2 control register 0c1 h 0c3 h 0c5 h 0c7 h 0c2 h 0c4 h 0c6 h 0cb h 0ca h 0c0 h 0cd h 0cc h 0c8 h
semiconductor group 86 on-chip peripheral components event counter mode in the counter function, the timer 2 is incremented in response to a 1-to-0 transition at its corresponding external input pin t2 (p1.7). in this function, the external input is sampled every machine cycle. when the sampled inputs show a high in one cycle and a low in the next cycle, the count is incremented. the new count value appears in the timer register in the cycle following the one in which the transition was detected. since it takes two machine cycles (24 oscillator periods) to recognize a 1-to-0 transition, the maximum count rate is 1/24 of the oscillator frequency. there are no restrictions on the duty cycle of the external input signal, but to ensure that a given level is sampled at least once before it changes, it must be held for at least one full machine cycle (see also section 7.1 "parallel i/o" for the exact sample time at the port pin p1.7). note: the prescaler must be off for proper counter operation of timer 2, i.e. t2ps must be 0. in either case, no matter whether timer 2 is configured as timer, event counter, or gated timer, a rolling-over of the count from all 1s to all 0s sets the timer overflow flag tf2 (bit 6 in sfr ircon, interrupt request control) which can generate an interrupt. lf tf2 is used to generate a timer overflow interrupt, the request flag must be cleared by the interrupt service routine as it could be necessary to check whether it was the tf2 flag or the external reload request flag exf2 which requested the interrupt (for exf2 see below). both request flags cause the program to branch to the same vector address. the input clock to timer 2 is selected by bits t2i0, t2i1, and t2ps as listed in figure 7-35 . reload of timer 2 ( see figure 7-33 b) ) the reload mode for timer 2 is selected by bits t2r0 and t2r1 in sfr t2con as listed in figure 7-35 . two reload modes are selectable: in mode 0 , when timer 2 rolls over from all 1s to all 0s, it not only sets tf2 but also causes the timer 2 registers to be loaded with the 16-bit value in the crc register, which is preset by software. the reload will happen in the same machine cycle in which tf2 is set, thus overwriting the count value 0000 h . in mode 1 , a 16-bit reload from the crc register is caused by a negative transition at the corresponding input pin t2ex/p1.5. in addition, this transition will set flag exf2, if bit exen2 in sfr ien1 is set. lf the timer 2 interrupt is enabled, setting exf2 will generate an interrupt (more about interrupts in section 8). the external input pin t2ex is sampled in every machine cycle. when the sampling shows a high in one cycle and a low in the next cycle, a transition will be recognized. the reload of timer 2 registers will then take place in the cycle following the one in which the transition was detected.
semiconductor group 87 on-chip peripheral components figure 7-34 special function register t2con timer 2 control register. bit-addressable register which controls timer 2 function and compare mode of registers crc, cc1 to cc3. bit symbol t2i1 t2i0 00 01 10 11 timer 2 input selection no input selected, timer 2 stops timer function input frequency = f osc /12 (t2ps = 0) or f osc /24 (t2ps = 1) counter function, external input signal at pin t2/p1.7 gated timer function, input controlled by pin t2/p1.7 t2r1 t2r0 0x 10 11 timer 2 reload mode selection reload disabled mode 0: auto-reload upon timer 2 overflow (tf2) mode 1: reload upon falling edge at pin t2ex/p1.5 t2cm compare mode bit for registers crc, cc1 through cc3. when set, compare mode 1 is selected. t2cm = 0 selects compare mode 0. i3fr external interrupt 3 falling/rising edge flag, also used for capture function in combination with register crc (see section 7.5.3). if set, capture to register to crc (if enabled) will occur on a positive transition at pin p1.0/int3 /cc0. if i3fr is cleared, capture will occur on a negative transition. t2ps prescaler select bit. when set, timer 2 is clocked in the "timer" or "gated timer" function with 1/24 of the oscillator frequency. t2ps = 0 gates f osc /12 to timer 2. t2ps must be 0 for the counter operation of timer 2. these bits are not used in combination with timer 2. 0cf h 0ce h 0cd h 0cc h 0cb h 0ca h 0c9 h 0c8 h t2ps i3fr i2fr t2r1 t2r0 t2cm t2i1 t2i0 0c8 h t2con
semiconductor group 88 on-chip peripheral components 7.5.2 compare function of registers crc, cc1 to cc3 the compare function of a timer/register combination can be described as follows. the 16-bit value stored in a compare/capture register is compared with the contents of the timer register. lf the count value in the timer register matches the stored value, an appropriate output signal is generated at a corresponding port pin, and an interrupt is requested. the contents of a compare register can be regarded as time stamp at which a dedicated output reacts in a predefined way (either with a positive or negative transition). variation of this time stamp somehow changes the wave of a rectangular output signal at a port pin. this may - as a variation of the duty cycle of a periodic signal - be used for pulse width modulation as well as for a continually controlled generation of any kind of square wave forms. in the case of the sab 80(c)515, two compare modes are implemented to cover a wide range of possible applications. the compare modes 0 and 1 are selected by bit t2cm in special function register t2con ( see figure 7-34 ). in both compare modes, the new value arrives at the port pin 1 within the same machine cycle in which the internal compare signal is activated. the four registers crc, cc1 to cc3 are multifunctional as they additionally provide a capture, compare or reload capability (the crc register only, see section 7.5.1). a general selection of the function is done in register ccen ( see figure 7-40 ). please note that the compare interrupt cc0 can be programmed to be negative or positive transition activated. the internal compare signal (not the output signal at the port pin!) is active as long as the timer 2 contents is equal to the one of the appropriate compare registers, and it has a rising and a falling edge. thus, when using the crc register, it can be selected whether an interrupt should be caused when the compare signal goes active or inactive, depending on bit i3fr in t2con. for the cc registers 1 to 3 an interrupt is always requested when the compare signal goes active ( see figure 7-36 ). 7.5.2.1 compare mode 0 in mode 0, upon matching the timer and compare register contents, the output signal changes from low to high. lt goes back to a low level on timer overflow. as long as compare mode 0 is enabled, the appropriate output pin is controlled by the timer circuit only, and not by the user. writing to the port will have no effect. figure 7-35 shows a functional diagram of a port latch in compare mode 0. the port latch is directly controlled by the two signals timer overflow and compare. the input line from the internal bus and the write-to-latch line are disconnected when compare mode 0 is enabled. compare mode 0 is ideal for generating pulse width modulated output signals, which in turn can be used for digital-to-analog conversion via a filter network or by the controlled device itself (e.g. the inductance of a dc or ac motor). mode 0 may also be used for providing output clocks with initially defined period and duty cycle. this is the mode which needs the least cpu time. once set up, the output goes on oscillating without any cpu intervention. figure 7-36 and 7-37 illustrate the function of compare mode 0.
semiconductor group 89 on-chip peripheral components figure 7-35 port latch in compare mode 0 figure 7-36 timer 2 with registers ccx in compare mode 0 (ccx stands for crc, cc1 to cc3; iexx stands for iex3 to iex6)
semiconductor group 90 on-chip peripheral components figure 7-37 function of compare mode 0 modulation range in compare mode 0 generally it can be said that for every pwm generation in compare mode 0 with n-bit wide compare registers there are 2 n different settings for the duty cycle. starting with a constant low level (0% duty cycle) as the first setting, the maximum possible duty cycle then would be this means that a variation of the duty cycle from 0% to real 100% can never be reached if the compare register and timer register have the same length. there is always a spike which is as long as the timer clock period. this "spike" may either appear when the compare register is set to the reload value (limiting the lower end of the modulation range) or it may occur at the end of a timer period. in a timer 2/ccx register configuration in compare mode 0 this spike is divided into two halves: one at the beginning when the contents of the compare register is equal to the reload value of the timer; the other half when the compare register is equal to the maximum value of the timer register (here: 0ffff h ). please refer to figure 7-38 where the maximum and minimum duty cycle of a compare output signal is illustrated. timer 2 is incremented with the machine clock ( f osc /12), thus at 12-mhz operational frequency, these spikes are both approx. 500 ns long. mct01906 timer count = ffff timer count = compare value contents of timer 2 timer count = reload value interrupt can be generated on overflow compare output (p1.x/ccx) interrupt can be generated on compare-match ~ ~ ~ ~ h (1 C 1/2 n ) x 100%
semiconductor group 91 on-chip peripheral components figure 7-38 modulation range of a pwm signal, generated with a timer 2/ccx register combination in compare mode 0 the following example shows how to calculate the modulation range for a pwm signal. to calculate with reasonable numbers, a reduction of the resolution to 8-bit is used. otherwise (for the maximum resolution of 16-bit) the modulation range would be so severely limited that it would be negligible. example: timer 2 in auto-reload mode; contents of reload register crc = 0ff00 h this leads to a variation of the duty cycle from 0.195% to 99.805% for a timer 2/ccx register configuration when 8 of 16 bits are used. restriction of modulation range = 1 256 x 2 x 100% = 0.195%
semiconductor group 92 on-chip peripheral components 7.5.2.2 compare mode 1 in compare mode 1, the software adaptively determines the transition of the output signal. lt is commonly used when output signals are not related to a constant signal period (as in a standard pwm generation) but must be controlled very precisely with high resolution and without jitter. in compare mode 1, both transitions of a signal can be controlled. compare outputs in this mode can be regarded as high speed outputs which are independent of the cpu activity. lf mode 1 is enabled, and the software writes to the appropriate output latch at the port, the new value will not appear at the output pin until the next compare match occurs. thus, one can choose whether the output signal is to make a new transition (1-to-0 or 0-to-1, depending on the actual pin- level) or should keep its old value at the time the timer 2 count matches the stored compare value. figure 7-39 shows a functional diagram of a timer/compare register/port latch configuration in compare mode 1. in this function, the port latch consists of two separate latches. the upper latch (which acts as a "shadow latch") can be written under software control, but its value will only be transferred to the output latch (and thus to the port pin) in response to a compare match. note that the double latch structure is transparent as long as the internal compare signal is active. while the compare signal is active, a write operation to the port will then change both latches. this may become important when driving timer 2 with a slow external clock. in this case the compare signal could be active for many machine cycles in which the cpu could unintentionally change the contents of the port latch. for details see also section 7.5.2.3 "using interrupts in combination with the compare function". a read-modify-write instruction (see section 7.1) will read the user-controlled "shadow latch" and write the modified value back to this "shadow-latch". a standard read instruction will - as usual - read the pin of the corresponding compare output.
semiconductor group 93 on-chip peripheral components figure 7-39 timer 2 with registers ccx in compare mode 1 (ccx stands for crc, cc1 to cc3; iexx stands for iex3 to iex6)
semiconductor group 94 on-chip peripheral components figure 7-40 special function register ccen compare/capture enable register selects compare or capture function for register crc, cc1 to cc3. 7.5.2.3 using interrupts in combination with the compare function the compare service of registers crc, cc1, cc2 and cc3 is assigned to alternate output functions at port pins p1.0 to p1.3. another option of these pins is that they can be used as external interrupt inputs. however, when using the port lines as compare outputs then the input line from the port pin to the interrupt system is disconnected (but the pins level can still be read under software control). thus, a change of the pins level will not cause a setting of the corresponding interrupt flag. in this case, the interrupt input is directly connected to the (internal) compare signal thus providing a compare interrupt . bit function cocah0 cocal0 00 01 10 11 compare/capture mode for crc register compare/capture disabled capture on falling/rising edge at pin p1.0/int3 /cc0 compare enabled capture on write operation into register crcl cocah1 cocal1 00 01 10 11 compare/capture mode for cc register 1 compare/capture disabled capture on rising edge at pin p1.1/int4/cc1 compare enabled capture on write operation into register ccl1 cocah2 cocal2 00 01 10 11 compare/capture mode for cc register 2 compare/capture disabled capture on rising edge at pin p1.2/int5/cc2 compare enabled capture on write operation into register ccl2 cocah3 cocal3 00 01 10 11 compare/capture mode for cc register 3 compare/capture disabled capture on rising edge at pin p1.3/int6/cc3 compare enabled capture on write operation into register ccl3 cocah3 cocal3 cocah2 cocai2 cocah1 cocal1 cocah0 cocal0 0c1 h ccen
semiconductor group 95 on-chip peripheral components the compare interrupt can be used very effectively to change the contents of the compare registers or to determine the level of the port outputs for the next "compare match". the principle is, that the internal compare signal (generated at a match between timer count and register contents) not only manipulates the compare output but also sets the corresponding interrupt request flag. thus, the current task of the cpu is interrupted - of course provided the priority of the compare interrupt is higher than the present task priority - and the corresponding interrupt service routine is called. this service routine then sets up all the necessary parameters for the next compare event. some advantages in using compare interrupts: firstly, there is no danger of unintentional overwriting a compare register before a match has been reached. this could happen when the cpu writes to the compare register without knowing about the actual timer 2 count. secondly, and this is the most interesting advantage of the compare feature, the output pin is exclusively controlled by hardware therefore completely independent from any service delay which in real time applications could be disastrous. the compare interrupt in turn is not sensitive to such delays since it loads the parameters for the next event. this in turn is supposed to happen after a sufficient space of time. please note two special cases where a program using compare interrupts could show a "surprising" behavior: the first configuration has already been mentioned in the description of compare mode 1. the fact that the compare interrupts are transition activated becomes important when driving timer 2 with a slow external clock. in this case it should be carefully considered that the compare signal is active as long as the timer 2 count is equal to the contents of the corresponding compare register, and that the compare signal has a rising and a falling edge. furthermore, the "shadow latches" used in compare mode 1 are transparent while the compare signal is active. thus, with a slow input clock for timer 2, the comparator signal is active for a long time (= high number of machine cycles) and therefore a fast interrupt controlled reload of the compare register could not only change the "shadow latch" - as probably intended - but also the output buffer. when using the crc , you can select whether an interrupt should be generated when the compare signal goes active or inactive, depending on the status of bit i3fr in t2con ( see figure 8-5 ). initializing the interrupt to be negative transition triggered is advisive in the above case. then the compare signal is already inactive and any write access to the port latch just changes the contents of the "shadow-latch". please note that for cc registers 1 to 3 an interrupt is always requested when the compare signal goes active.
semiconductor group 96 on-chip peripheral components the second configuration which should be noted is when compare function is combined with negative transition activated interrupts. lf the port latch of port p1.0 contains a 1, the interrupt request flags iex2 will immediately be set after enabling the compare mode for the crc register. the reason is that first the external interrupt input is controlled by the pins level. when the compare option is enabled the interrupt logic input is switched to the internal compare signal, which carries a low level when no true comparison is detected. so the interrupt logic sees a 1-to-0 edge and sets the interrupt request flag. an unintentional generation of an interrupt during compare initialization can be prevented if the request flag is cleared by software after the compare is activated and before the external interrupt is enabled. 7.5.3 capture function each of the three compare/capture registers cc1 to cc3 and the crc register can be used to latch the current 16-bit value of the timer 2 registers tl2 and th2. two different modes are provided for this function. in mode 0, an external event latches the timer 2 contents to a dedicated capture register. in mode 1, a capture will occur upon writing to the low order byte of the dedicated 16-bit capture register. this mode is provided to allow the software to read the timer 2 contents "on-the- fly". in mode 0, the external event causing a capture is C for cc registers 1 to 3: a positive transition at pins cc1 to cc3 of port 1 C for the crc register: a positive or negative transition at the corresponding pin, depending on the status of the bit i3fr in sfr t2con. lf the edge flag is cleared, a capture occurs in response to a negative transition; if the edge flag is set a capture occurs in response to a positive transition at pin p1.0/int3 / cc0. in both cases the appropriate port 1 pin is used as input and the port latch must be programmed to contain a one (1). the external input is sampled in every machine cycle. when the sampled input shows a low (high) level in one cycle and a high (low) in the next cycle, a transition is recognized. the timer 2 contents is latched to the appropriate capture register in the cycle following the one in which the transition was identified. in mode 0 a transition at the external capture inputs of registers cc0 to cc3 will also set the corresponding external interrupt request flags iex3 to iex6. lf the interrupts are enabled, an external capture signal will cause the cpu to vector to the appropriate interrupt service routine. in mode 1 a capture occurs in response to a write instruction to the low order byte of a capture register. the write-to-register signal (e.g. write-to-crcl) is used to initiate a capture. the value written to the dedicated capture register is irrelevant for this function. the timer 2 contents will be latched into the appropriate capture register in the cycle following the write instruction. in this mode no interrupt request will be generated.
semiconductor group 97 on-chip peripheral components figures 7-41 and 7-42 show functional diagrams of the capture function of timer 2. figure 7-41 illustrates the operation of the crc register, while figure 7-42 shows the operation of the compare/ capture registers 1 to 3. the two capture modes can be established individually for each capture register by bits in sfr ccen (compare/capture enable register). that means, in contrast to the compare modes, it is possible to simultaneously select mode 0 for one capture register and mode 1 for another register. the bit positions and functions of ccen are listed in figure 7-40 . figure 7-41 capture with register crc
semiconductor group 98 on-chip peripheral components figure 7-42 capture with registers cc1 to cc3 7.6 power saving modes for significantly reducing power consumption, the sab 80(c)515/80(c)535 provides two power saving modes: C the power-down mode operation of the component stops completely, the oscillator is turned off. only the internal ram is supplied with a very low standby current. C the idle mode (sab 80c515/80c535 only) the cpu is gated off from the oscillator. all peripherals are further supplied by the oscillator clock and are able to do their jobs. these modes are described separatly for each component in the following sections. there are numerous applications which require high system security and at the same time reliability in electrically noisy environments. in such applications unintentional entering of the power saving modes must be absolutely avoided. a power saving mode would reduce the controllers perfomance (in case of idle mode) or even stop each operation (in case of power-down mode). this situation might be fatal for the system. such critical applications often use the watchdog timer to prevent the system from program upsets. then accidental entering of the power saving modes would even stop the watchdog timer and would circumvent the task of system reliability. the sab 80c515/80c535 provides software and hardware protection against accidental entering as described above (see chapter 7.6.2).
semiconductor group 99 on-chip peripheral components 7.6.1 power saving modes of the sab 80515/80535 the sab 80515/80535 allows a reduction of the power consumption using the power-down mode. 7.6.1.1 power-down mode of the sab 80515/80535 the power-down mode in the sab 80515/80535 allows a reduction of v cc , to zero while saving 40 bytes of the on-chip ram through a backup supply connected to the v pd pin. in the following, the terms v cc and v pd are used to specify the voltages on pin v cc and pin v pd , respectively. lf v cc > v pd , the 40 bytes are supplied from v cc . v pd may then below. lf v cc < v pd , the current for the 40 bytes is drawn from v pd . the addresses of these backup-powered ram locations range from 88 to 127 (58 h to 7f h ). the current drawn from the backup power supply is typically 1 ma, max. 3 ma. to utilize this feature, the users system - upon detecting an imminent power failure - would interrupt the processor in some manner to transfer relevant data to the 40-byte on-chip ram and enable the backup power supply to the v pd pin. then a reset should be accomplished before v cc falls below its operating limit. when power returns, a power-on reset should be accomplished, and the backup supply needs to stay on long enough to resume normal operation. figure 7-43 illustrates the timing upon a power failure. figure 7-43 reset and ram backup power timing of the sab 80515/80535
semiconductor group 100 on-chip peripheral components 7.6.2 power saving modes of the sab 80515/80535 dlfferences between the power-down modes of the sab 80c515/80c535 and the sab 80515/ 80535 the power-down mode of the sab 80515/80535 allows retention of 40 bytes on-chip ram through a backup supply connected to the v pd pin. the acmos versions sab 80c515/80c535 have the following additional features: C the same power supply (pin v cc ) for active, power-down (retention of the whole int. ram area), and idle mode. C an extra pin (pe ) that allows enabling/disabling of the power-saving modes. C a software protection that enables the power saving modes via special function register pcon (power control register). hardware enable for the use of the power saving modes to provide power saving modes together with effective protection against unintentional entering of these modes, the sab 80c515/80c535 has an extra pin for disabling the use of the power saving modes. this pin is called pe (power saving enable ), and its function is as follows: pe = 1 (logic high level): use of the power saving modes is not possible. the instruction sequences used for entering these modes will not affect the normal operation of the device. pe = 0 (logic low level): all power saving modes can be activated as described in the following sections. when left unconnected, the pin pe is pulled to high level by a weak internal pullup. this is done to provide system protection by default. in addition to the hardware enable/disable of the power saving modes, a double-instruction sequence which is described in the corresponding sections is necessary to enter power-down and idle mode. the combination of all these safety precautions provides a maximum of system protection. application example for switching pin pe for most applications in noisy environments, certain components external to the chip are used to give warning of a power failure or a turn off of the power supply. these circuits could be used to control the pe pin. the possible steps to go into power-down mode could then be as follows: C a power-fail signal forces the controller to go into a high priority interrupt routine. this interrupt routine saves the actual program status. at the same time pin pe is pulled low by the power- fail signal. C finally the controller enters power-down mode by executing the relevant double-instruction sequence.
semiconductor group 101 on-chip peripheral components 7.6.2.1 power-down mode of the sab 80c515/80c535 in the power-down mode, the on-chip oscillator is stopped. therefore, all functions are stopped, only the contents of the on-chip ram and the sfrs are held. the port pins controlled by their port latches output the values that are held by their sfrs. the port pins which serve the alternate output functions show the values they had at the end of the last cycle of the instruction which initiated the power-down mode; when enabled, the clockout signal (p1.6/clkout) will stop at low level. ale and psen are held at logic low level ( see table 7-10 ). lf the power-down mode is to be used, the pin pe must be held low. entering the power-down mode is done by two consecutive instructions immediately following each other. the first instruction has to set the flag bit pde (pcon.1) and must not set bit pds (pcon.6). the following instruction has to set the start bit pds (pcon.6) and must not set bit pde (pcon.1). the hardware ensures that a concurrent setting of both bits, pde and pds, will not initiate the power-down mode. bit pde and pds will automatically be cleared after having been set and the value shown when reading one of these bits is always zero (0). figure 7-44 shows the special function register pcon. this double- instruction sequence is implemented to minimize the chance of unintentionall entering the power- down mode, which could possibly "freeze" the chips activity in an undesired status. note that pcon is not a bit-addressable register, so the above mentioned sequence for entering the power-down mode is composed of byte handling instructions. the following instruction sequence may serve as an example: orl pcon,#00000010b ;set bit pde, ;bit pds must not be set orl pcon,#01000000b ;set bit pds, ;bit pde must not be set the instruction that sets bit pds is the last instruction executed before going into power-down mode. lf idle mode and power-down mode are invoked simultaneously, the power-down mode takes precedence. the only exit from power-down mode is a hardware reset. reset will redefine all sfrs, but will not change the contents of the internal ram. in the power-down mode, v cc can be reduced to minimize power consumption. care must be taken, however, to ensure that v cc is not reduced before the power-down mode is invoked, and that v cc is restored to its normal operating level before the power-down mode is terminated. the reset signal that terminates the power-down mode also frees the oscillator. the reset should not be activated before v cc is restored to its normal operating level and must be held active long enough to allow the oscillator to restart and stabilize (similar to power-on reset).
semiconductor group 102 on-chip peripheral components 7.6.2.2 idle mode of the sab 80c515/80c535 in idle mode the oscillator of the sab 80c515/80c535 continues to run, but the cpu is gated off from the clock signal. however, the interrupt system, the serial channel, the a/d converter and all timers, except for the watchdog timer, are further provided with the clock. the cpu status is preserved in its entirety: the stack pointer, program counter, program status word, accumulator, and all other registers maintain their data during idle mode. the reduction of power consumption, which can be achieved by this feature, depends on the number of peripherals running. lf all timers are stopped and the a/d converter and the serial interface are not running, maximum power reduction can be achieved. this state is also the test condition for the idle i cc (see the dc characteristics in the data sheet). thus, the user has to make sure that the right peripheral continues to run or is stopped, respectively, during idle. also, the state of all port pins - either the pins controlled by their latches or controlled by their secondary functions - depends on the status of the controller when entering idle. normally the port pins hold the logical state they had at the time idle was activated. lf some pins are programmed to serve their alternate functions they still continue to output during idle if the assigned function is on. this applies for the compare outputs as well as for the system clock output signal and the serial interface in case the latter could not finish reception or transmission during normal operation. the control signals ale and psen are held at logic high levels ( see table 7-10 ). during idle, as in normal operating mode, the ports can be used as inputs. thus, a capture or reload operation as well as an a/d conversion can be triggered, the timers can be used to count external events and external interrupts can be detected.
semiconductor group 103 on-chip peripheral components table 7-10 status of external pins during idle and power-down mode the watchdog timer is the only peripheral which is automatically stopped during idle. the idle mode makes it possible to "freeze" the processors status for a certain time or until an external event causes the controller to go back into normal operating mode. since the watchdog timer is stopped during idle mode, this useful feature of the sab 80c515/80c535 is provided even if the watchdog function is used simultaneously. lf the idle mode is to be used the pin pe must be held low. entering the idle mode is to be done by two consecutive instructions immediately following each other. the first instruction has to set the flag bit idle (pcon.0) and must not set bit idls (pcon.5), the following instruction has to set the start bit idls (pcon.5) and must not set bit idle (pcon.0). the hardware ensures that a concurrent setting of both bits, idle and idls will not initiate the idle mode. bits idle and idls will automatically be cleared after having been set. lt one of these register bits is read the value shown is zero (0). figure 7-44 shows special function register pcon. this double-instruction sequence is implemented to minimize the chance of unintentionally entering the idle mode. note that pcon is not a bit-addressable register, so the above mentioned sequence for entering the idle mode is to be done by byte handling instructions. outputs last instruction executed from internal code memory last instruction executed from external code memory idle power-down idle power-down ale high low high low psen high low high low port 0 data data float float port 1 data/alternate outputs data/ last output data/alternate outputs data/ last output port 2 data data address data port 3 data/alternate outputs data/ last output data/alternate outputs data/ last output port 4datadatadatadata port 5datadatadatadata
semiconductor group 104 on-chip peripheral components the following instruction sequence may serve as an exemple: orl pcon,#00000001b ;set bit idle, ;bit idls must not be set orl pcon,#00100000b ;set bit idls, ;bit idle must not be set the instruction that sets bit idls is the last instruction executed before going into idle mode. terminating the idle mode C the idle mode can be terminated by activation of any enabled interrupt. the cpu operation is resumed, the interrupt will be serviced and the next instruction to be executed after the reti instruction will be the one following the instruction that set the bit idls. C the other possibility of terminating the idle mode is a hardware reset. since the oscillator is still running, the hardware reset is held active for only two machine cycles for a complete reset. figure 7-44 special function register pcon (address 87 h ) of the sab 80c515/80c535 bit function pds power-down start bit. the instruction that sets the pds flag bit is the last instruction before entering the power-down mode. idls idle start bit. the instruction that sets the idsl flag bit is the last instruction before entering the idle mode. gf1 general purpose flag gf0 general purpose flag pde power-down enable bit. when set, starting the power-down mode is enabled. idle idle mode enable bit. when set, starting the idle mode is enabled. these bits are not used in controlling the power saving modes. smod pds idls C gf1 gf0 pde idle 87 h pcon
semiconductor group 105 on-chip peripheral components 7.7 watchdog timer as a means of graceful recovery from software or hardware upset a watchdog timer is provided in the sab 80(c)515/80(c)535. lf the software fails to clear the watchdog timer at least every 65532 m s, an internal hardware reset will be initiated. the software can be designed such that the watchdog times out if the program does not progress properly. the watchdog will also time out if the software error was due to hardware-related problems. this prevents the controller from malfunctioning for longer than 65 ms if a 12-mhz oscillator is used. the watchdog timer is a 16-bit counter which is incremented once every machine cycle. after an external reset the watchdog timer is disabled and cleared to 0000 h . the counter is started by setting bit swdt (bit 6 in sfr ien1). after having been started, the bit wdts (watchdog timer status, bit 6 in sfr ip0) is set. note that the watchdog timer cannot be stopped by software. lt can only be cleared to 0000 h by first setting bit wdt (ien0.6) and with the next instruction setting swdt. bit wdt will automatically be cleared during the second machine cycle after having been set. for this reason, setting swdt bit has to be a one cycle instruction (e.g. setb swdt). this double instruction clearing of the watchdog timer was implemented to minimize the chance of unintentionally clearing the watchdog. to prevent the watchdog from overflowing, it must be cleared periodically. starting the watchdog timer by setting only bit swdt does not reload the wdtrel register to the watchdog timer registers wdtl/wdth. a reload occurs only by using the double instruction refresh sequence setb wdt / setb swdt. lf the software fails to clear the watchdog in time, an internally generated watchdog reset is entered at the counter state fffc h , which lasts four machine cycles. this internal reset differs from an external reset only to the extent that the watchdog timer is not disabled. bit wdts (was set by starting wdt) allows the software to examine from which source the reset was initiated. lf it is set, the reset was caused by a watchdog timer overflow. figure 7-45 special function register ien0 bit function wdt watchdog timer refresh flag. set to initiate a refresh of the watchdog timer. must be set directly before swdt is set to prevent an unintentional refresh of the watchdog timer. wdt is reset by hardware two processor cycles after it has been set. these bits are not used by the watchdog timer. 0af h 0ae h 0ad h 0ac h 0ab h 0aa h 0a9 h 0a8 h eal wdt et2 es et1 ex1 et0 ex0 0a8 h ien0
semiconductor group 106 on-chip peripheral components figure 7-46 special function register ien1 figure 7-47 special function register ip0 bit function swdt watchdog timer start/refresh flag. set to activate/refresh the watchdog timer. when directly set after setting wdt, a watchdog timer refresh is performed. bit swdt is reset by hardware two processor cycles after it has been set. bit function wdts watchdog timer status flag. set by hardware when the watchdog timer was started. can be read by software. these bits are not used by the watchdog timer. 0bf h 0be h 0bd h 0bc h 0bb h 0ba h 0b9 h 0b8 h exen2 swdt ex6 ex5 ex4 ex3 ex2 eadc 0b8 h ien1 these bits are not used by the watchdog timer. C wdts ip0.5 ip0.4 ip0.3 ip0.2 ip0.1 ip0.0 0a9 h ip0
semiconductor group 107 on-chip peripheral components 7.8 oscillator and clock circuit xtal1 and xtal2 are the input and output of a single-stage on-chip inverter which can be configured with off-chip components as a pierce oscillator. the oscillator, in any case, drives the internal clock generator. the clock generator provides the internal clock signals to the chip at half the oscillator frequency. these signals define the internal phases, states and machine cycles, as described in chapter 3. 7.8.1 crystal oscillator mode figure 7-48 shows the recommended oscillator circuit. figure 7-48 recommended oscillator circuit for the sab 80(c)515/80(c)535 in this application the on-chip oscillator is used as a crystal-controlled, positive-reactance oscillator (a more detailed schematic is given in figure 7-49 and 7-51 ). lt is operated in its fundamental response mode as an inductive reactor in parallel resonance with a capacitor external to the chip. the crystal specifications and capacitances are non-critical. in this circuit 30 pf can be used as single capacitance at any frequency together with a good quality crystal. a ceramic resonator can be used in place of the crystal in cost-critical applications. lf a ceramic resonator is used, c 1 and c 2 are normally selected to be different values. we recommend consulting the manufacturer of the ceramic resonator for value specifications of these capacitors. 7.8.2 driving for external source the sab 80(c)515/80(c)535 can be driven from an external oscillator. please note that there is a difference between driving mymos and acmos devices from an external clock source.
semiconductor group 108 on-chip peripheral components 7.8.2.1 driving the sab 80515/80535 from external source for driving the sab 80515/80535 from an external clock source, the external clock signal is to be applied to xtal2. a pullup resistor is recommended to increase the noise margin, but is optional if the output high level of the driving gate meets the v ih1 specification of xtal2. xtal1 has to be connected to ground ( see figure 7-50 ). figure 7-49 on-chip oscillator circuitry figure 7-50 external clock source
semiconductor group 109 on-chip peripheral components 7.8.2.2 driving the sab 80c515/80c535 from external source for driving the sab 80c515/80c535 from an external clock source, the external clock signal is to be applied to xtal2, as shown in figure 7-52 . a pullup resistor is recommended, but is optional if the output high level of the driving gate corresponds to the v ih1 specification of xtal2. xtal1 has to be left unconnected. figure 7-51 on-chip oscillator circuitry figure 7-52 external clock source
semiconductor group 110 on-chip peripheral components 7.9 system clock output for peripheral devices requiring a system clock, the sab 80(c)515/80(c)535 provides a clock output signal derived from the oscillator frequency as an alternate output function on pin p1.6/ clkout. lf bit clk is set (bit 6 of special function register adcon, see figure 7-53 ), a clock signal with 1/12 of the oscillator frequency is gated to pin p1.6/clkout. to use this function the port pin must be programmed to a one (1), which is also the default after reset. figure 7-53 special function register adcon (address 0d8 h ) the system clock is high during s3p1 and s3p2 of every machine cycle and low during all other states. thus, the duty cycle of the clock signal is 1:6. associated with a movx instruction the system clock coincides with the last state (s3) in which a rd or wr signal is active. a timing diagram of the system clock output is shown in figure 7-54 . bit function clk clockout enable bit. when set, pin p1.6/clkout outputs the system clock which is 1/12 of the oscillator frequency. these bits are not used in controlling the clock out functions. 0df h 0de h 0dd h 0dc h 0db h 0da h 0d9 h 0d8 h bd clk C bsy adm mx2 mx1 mx0 0d8 h adcon
semiconductor group 111 on-chip peripheral components figure 7-54 timing diagram - system clock output
semiconductor group 112 interrupt system 8 interrupt system the sab 80c515/80c535 provides 12 interrupt sources with four priority levels. five interrupts can be generated by the on-chip peripherals (i.e. timer 0, timer 1, timer 2, compare timer, serial interface and a/d converter), and seven interrupts may be triggered externally ( see figure 8.1 ). 8.1 interrupt structure a common mechanism is used to generate the various interrupts, each source having its own request flag(s) located in a special function register (e.g. tcon, ircon, scon). provided that the peripheral or external source meets the condition for an interrupt, the dedicated request flag is set, whether an interrupt is enabled or not. for example, each timer 0 overflow sets the corresponding request flag tf0. lf it is already set, it retains a one (1). but the interrupt is not necessarily serviced. now each interrupt requested by the corresponding flag can individually be enabled or disabled by the enable bits in sfrs ien0, ien1 ( see figure 8-2, 8-3 ). this determines whether the interrupt will actually be performed. in addition, there is a global enable bit for all interrupts which, when cleared, disables all interrupts independent of their individual enable bits.
semiconductor group 113 interrupt system figure 8-1 a) interrupt structure of the sab 80(c)515/80(c)535
semiconductor group 114 interrupt system figure 8-1 b) interrupt structure of the sab 80(c)515/80(c)535 (contd)
semiconductor group 115 interrupt system figure 8-2 special function register ien0 (address 0a8 h ) bit function ex0 enables or disables external interrupt 0. if ex0 = 0, external interrupt 0 is disabled. et0 enables or disables the timer 0 overflow interrupt. if et0 = 0, the timer 0 interrupt is disabled. ex1 enables or disables external interrupt 1. if ex1 = 0, external interrupt 1 is disabled. et1 enables or disables the timer 1 overflow interrupt. if et1 = 0, the timer 1 interrupt is disabled. es enables or disables the serial channel interrupt. if es = 0, the serial channel interrupt is disabled. et2 enables or disables the timer 2 overflow or external reload interrupt. if et2 = 0, the timer 2 interrupt is disabled. eal enables or disables all interrupts. if eal = 0, no interrupt will be acknowledged. if eal = 1, each interrupt source is individually enabled or disabled by setting or clearing its enable bit. 0af h 0ae h 0ad h 0ac h 0ab h 0aa h 0a9 h 0a8 h eal wdt et2 es et1 ex1 et0 ex0 0a8 h ien0 this bit is not used for interrupt control.
semiconductor group 116 interrupt system figure 8-3 special function register ien1 (address 0b8 h ) in the following the interrupt sources are discussed individually. the external interrupts 0 and 1 (int0 and int1 ) can each be either level-activated or negative transition-activated, depending on bits it0 and it1 in register tcon ( see figure 8-4 ). the flags that actually generate these interrupts are bits ie0 and le1 in tcon. when an external interrupt is generated, the flag that generated this interrupt is cleared by the hardware when the service routine is vectored too, but only if the interrupt was transition-activated. lf the interrupt was level-activated, then the requesting external source directly controls the request flag, rather than the on-chip hardware. the timer 0 and timer 1 interrupts are generated by tf0 and tf1 in register tcon, which are set by a rollover in their respective timer/counter registers (exception see section 7.3.4 for timer 0 in mode 3). when a timer interrupt is generated, the flag that generated it is cleared by the on-chip hardware when the service routine is vectored too. bit function eadc enables or disables the a/d converter interrupt. if eadc = 0, the a/d converter interrupt is disabled. ex2 enables or disables external interrupt 2/capture/compare interrupt 4. if ex2 = 0, external interrupt 2 is disabled. ex3 enables or disables external interrupt 3/capture/compare interrupt 0. if ex3 = 0, external interrupt 3 is disabled. ex4 enables or disables external interrupt 4/capture/compare interrupt 0. if ex4 = 0, external interrupt 4 is disabled. ex5 enables or disables external interrupt 5/capture/compare interrupt 0. if ex5 = 0, external interrupt 5 is disabled. ex6 enables or disables external interrupt 6/capture/compare interrupt 0 if ex6 = 0, external interrupt 6 is disabled. exen2 enables or disables the timer 2 external reload interrupt. exen2 = 0 disables the timer 2 external reload interrupt. the external reload function is not affected by exen2. 0bf h 0be h 0bd h 0bc h 0bb h 0ba h 0b9 h 0b8 h exen2 swdt ex6 ex5 ex4 ex3 ex2 eadc 0b8 h ien1 this bit is not used for interrupt control.
semiconductor group 117 interrupt system the serial port interrupt is generated by a logical or of flag ri and tl in sfr scon ( see figure 7-7 ). neither of these flags is cleared by hardware when the service routine is vectored too. in fact, the service routine will normally have to determine whether it was the receive interrupt flag or the transmission interrupt flag that generated the interrupt, and the bit will have to be cleared by software. the timer 2 interrupt is generated by the logical or of bit tf2 in register t2con and bit exf2 in register ircon. figures 8-5 and 8-6 show sfrs t2con and ircon. neither of these flags is cleared by hardware when the service routine is vectored to. in fact, the service routine may have to determine whether it was tf2 or exf2 that generated the interrupt, and the bit will have to be cleared by software. figure 8-4 special function register tcon (address 88 h ) the a/d converter interrupt is generated by iadc in register ircon ( see figure 8-6 ). lt is set some cycles before the result is available. that is, if an interrupt is generated, in any case the converted result in addat is valid on the first instruction of the interrupt service routine (with respect to the minimal interrupt response time). lf continuous conversions are established, iadc is set once during each conversion. lf an a/d converter interrupt is generated, flag iadc will have to be cleared by software. bit function it0 interrupt 0 type control bit. set/cleared by software to specify falling edge/low- level triggered external interrupts. ie0 interrupt 0 edge flag. set by hardware when external interrupt edge is detected. cleared when interrupt processed. it1 interrupt 1 type control bit. set/cleared by software to specify falling edge/low- level triggered external interrupts. ie1 interrupt 1 edge flag. set by hardware when external interrupt edge is detected. cleared when interrupt processed. tf0 timer 0 overflow flag. set by hardware on timer/counter overflow. cleared by hardware when processor vectors to interrupt routine. tf1 timer 1 overflow flag. set by hardware on timer/counter overflow. cleared by hardware when processor vectors to interrupt routine. 8f h 8e h c5 h 8c h 8b h 8a h 89 h 88 h tf1 tr1 tf0 tr0 ie1 it1 ie0 it0 88 h tcon these bits are not used for interrupt control.
semiconductor group 118 interrupt system the external interrupt 2 (int2 /) can be either positive or negative transition-activated depending on bit i2fr in register t2con ( see figure 8-5 ). the flag that actually generates this interrupt is bit iex2 in register ircon. lf an interrupt 2 is generated, flag iex2 is cleared by hardware when the service routine is vectored too. figure 8-5 special function register t2con (address 0c8 h ) like the external interrupt 2, the external interrupt 3 (int3 ) can be either positive or negative transition-activated, depending on bit i3fr in register t2con. the flag that actually generates this interrupt is bit iex3 in register ircon. in addition, this flag will be set if a compare event occurs at pin p1.0/int3 /cc0, regardless of the compare mode established and the transition at the respective pin. the flag iex3 is cleared by hardware when the service routine is vectored too. the external interrupts 4 (int4), 5 (int5), 6 (int6) are positive transition-activated. the flags that actually generate these interrupts are bits iex4, iex5, and iex6 in register ircon ( see figure 8-6 ). in addition, these flags will be set if a compare event occurs at the corresponding output pin p1.1/ int4/cc1, p1.2/int5/cc2, and p1.3/int6/cc3, regardless of the compare mode established and the transition at the respective pin. when an interrupt is generated, the flag that generated it is cleared by the on-chip hardware when the service routine is vectored too. bit function i2fr external interrupt 2 falling/rising edge flag. when set, the interrupt 2 request flag iex2 will be set on a positive transition at pin p1.4/int2 . i2fr = 0 specifies external interrupt 2 to be negative-transition activated. i3fr external interrupt 3 falling/rising edge flag. when set, the interrupt 3 request flag iex3 will be set on a positive transition at pin p1.0/int3 . i3fr = 0 specifies external interrupt 3 to be negative-transition active. 0cf h 0ce h 0cd h 0cc h 0cb h 0ca h 0c9 h 0c8 h t2ps i3fr i2fr t2r1 t2r0 t2cm t2i1 t2i0 0c8 h t2con these bits are not used for interrupt control.
semiconductor group 119 interrupt system figure 8-6 special function register ircon (address 0c0 h ) bit function iadc a/d converter interrupt request flag. set by hardware at the end of a conversion. must be cleared by software. iex2 external interrupt 2 edge flag. set by hardware when external interrupt edge was detected or when a compare event occurred at pin 1.4/int2 /cc4. cleared when interrupt processed. iex3 external interrupt 3 edge flag. set by hardware when external interrupt edge was detected or when a compare event occurred at pin 1.0/int3 /cc0. cleared when interrupt processed. iex4 external interrupt 4 edge flag. set by hardware when external interrupt edge was detected or when a compare event occurred at pin 1.1/int4/cc1. cleared when interrupt processed. iex5 external interrupt 5 edge flag. set by hardware when external interrupt edge was detected or when a compare event occurred at pin 1.2/int5/cc2. cleared when interrupt processed. iex6 external interrupt 6 edge flag. set by hardware when external interrupt edge was detected or when a compare event occurred at pin 1.3/int6/cc3. cleared when interrupt processed. tf2 timer 2 overflow flag. set by timer 2 overflow. must be cleared by software. if the timer 2 interrupt is enabled, tf2 = 1 will cause an interrupt. exf2 timer 2 external reload flag. set when a reload is caused by a negative transition on pin t2ex while exen2 = 1. when the timer 2 interrupt is enabled, exf2 = 1 will cause the cpu to vector the timer 2 interrupt routine. can be used as an additional external interrupt when the reload function is not used. exf2 must be cleared by software. 0c7 h 0c6 h 0c5 h 0c4 h 0c3 h 0c2 h 0c1 h 0c0 h exf2 tf2 iex6 iex5 iex4 iex3 iex2 iadc 0c0 h ircon
semiconductor group 120 interrupt system all of these bits that generate interrupts can be set or cleared by software, with the same result as if they had been set or cleared by hardware. that is, interrupts can be generated or pending interrupts can be cancelled by software. the only exceptions are the request flags ie0 and le1. lf the external interrupts 0 and 1 are programmed to be level-activated, ie0 and le1 are controlled by the external source via pin int0 and int1 , respectively. thus, writing a one to these bits will not set the request flag ie0 and/or le1. in this mode, interrupts 0 and 1 can only be generated by software and by writing a 0 to the corresponding pins int0 (p3.2) and int1 (p3.3), provided that this will not affect any peripheral circuit connected to the pins. each of these interrupt sources can be individually enabled or disabled by setting or clearing a bit in the special function registers ien0 and ien1 ( figures 8-2 and 8-3 ). note that ien0 contains also a global disable bit, eal, which disables all interrupts at once. also note that in the sab 8051 the interrupt priority register ip is located at address 0b8 h ; in the sab 80(c)515/80(c)535 this location is occupied by register ien1. 8.2 priority level structure as already mentioned above, all interrupt sources are combined as pairs; table 8-1 lists the structure of the interrupt sources. table 8-1 pairs of interrupt sources each pair of interrupt sources can be programmed individually to one of four priority levels by setting or clearing one bit in the special function register ip0 and one in ip1 ( figure 8-7 ). a low-priority interrupt can be interrupted by a high-priority interrupt, but not by another interrupt of the same or a lower priority. an interrupt of the highest priority level cannot be interrupted by another interrupt source. external interrupt 0 a/d converter interrupt timer 0 interrupt external interrupt 2 external interrupt 1 external interrupt 3 timer 1 interrupt external interrupt 4 serial channel 0 interrupt external interrupt 5 timer 2 interrupt external interrupt 6
semiconductor group 121 interrupt system lf two or more requests of different priority levels are received simultaneously, the request of the highest priority is serviced first. lf requests of the same priority level are received simultaneously, an internal polling sequence determines which request is to be serviced first. thus, within each priority level there is a second priority structure determined by the polling sequence, as follows ( see figure 8-8 ): C within one pair the "left" interrupt is serviced first C the pairs are serviced from top to bottom of the table. figure 8-7 special function registers ip0 and ip1 (address 0a9 h and 0b9 h ) corresponding bit locations in both registers are used to set the interrupt priority level of an interrupt pair. bit function ip1.x ip0.x C 0 0 set priority level 0 (lowest) 0 1 set priority level 1 1 0 set priority level 2 1 1 set priority level 3 (highest) bit function ip1.0/ip0.0 ie0/iadc ip1.1/ip0.1 tf0/iex2 ip1.2/ip0.2 ie1/iex3 ip1.3/ip0.3 tf1/iex4 ip1.4/ip0.4 ri + ti/iex5 ip1.5/ip0.5 tf2 + exf2/iex6 these bits are not used for interrupt control. wdts ip0.5 ip0.4 ip0.3 ip0.2 ip0.1 ip0.0 0a9 h ip0 CC ip1.5 ip1.4 ip1.3 ip1.2 ip1.1 ip1.0 0b9 h ip1 C
semiconductor group 122 interrupt system figure 8-8 priority-within-level structure note: this "priority-within-level" structure is only used to resolve simultaneous requests of the same priority level. 8.3 how interrupts are handled the interrupt flags are sampled at s5p2 in each machine cycle. the sampled flags are polled during the following machine cycle. lf one of the flags was in a set condition at s5p2 of the preceding cycle, the polling cycle will find it and the interrupt system will generate a lcall to the appropriate service routine, provided this hardware-generated lcall is not blocked by any of the following conditions: 1) an interrupt of equal or higher priority is already in progress. 2) the current (polling) cycle is not in the final cycle of the instruction in progress. 3) the instruction in progress is reti or any write access to registers ien0, ien1, ien2 or ip0 and ip1. any of these three conditions will block the generation of the lcall to the interrupt service routine. condition 2 ensures that the instruction in progress is completed before vectoring to any service routine. condition 3 ensures that if the instruction in progress is reti or any write access to registers ien0, ien1 or ip0 and ip1, then at least one more instruction will be executed before any interrupt is vectored too; this delay guarantees that changes of the interrupt status can be observed by the cpu. high ? low priority interrupt source ie0 iadc tf0 iex2 ie1 iex3 tf1 iex4 ri + ti iex5 tf2 + exf2 iex6 high low
semiconductor group 123 interrupt system the polling cycle is repeated with each machine cycle, and the values polled are the values that were present at s5p2 of the previous machine cycle. note that if any interrupt flag is active but not being responded to for one of the conditions already mentioned, or if the flag is no longer active when the blocking condition is removed, the denied interrupt will not be serviced. in other words, the fact that the interrupt flag was once active but not serviced is not remembered. every polling cycle interrogates only the pending interrupt requests. the polling cycle/lcall sequence is illustrated in figure 8-9 . figure 8-9 interrupt response timing diagram note that if an interrupt of a higher priority level goes active prior to s5p2 in the machine cycle labeled c3 in figure 8-9 , then, in accordance with the above rules, it will be vectored too during c5 and c6 without any instruction for the lower priority routine to be executed. thus, the processor acknowledges an interrupt request by executing a hardware-generated lcall to the appropriate servicing routine. in some cases it also clears the flag that generated the interrupt, while in other cases it does not; then this has to be done by the users software. the hardware clears the external interrupt flags ie0 and le1 only if they were transition-activated. the hardware-generated lcall pushes the contents of the program counter onto the stack (but it does not save the psw) and reloads the program counter with an address that depends on the source of the interrupt being vectored too, as shown in the following ( table 8-2 ).
semiconductor group 124 interrupt system table 8-2 interrupt sources and vectors execution proceeds from that location until the reti instruction is encountered. the reti instruction informs the processor that the interrupt routine is no longer in progress, then pops the two top bytes from the stack and reloads the program counter. execution of the interrupted program continues from the point where it was stopped. note that the reti instruction is very important because it informs the processor that the program left the current interrupt priority level. a simple ret instruction would also have returned execution to the interrupted program, but it would have left the interrupt control system thinking an interrupt was still in progress. in this case no interrupt of the same or lower priority level would be acknowledged. interrupt request flags interrupt vector address interrupt source ie0 0003 h external interrupt 0 tf0 000b h timer overflow ie1 0013 h external interrupt 1 tf1 001b h timer 1 overflow ri/ti 0023 h serial channel tf2/exf2 002b h timer 2 overflow/ext. reload iadc 0043 h a/d converter iex2 004b h external interrupt 2 iex3 0053 h external interrupt 3 iex4 005b h external interrupt 4 iex5 0063 h external interrupt 5 iex6 006b h external interrupt 6
semiconductor group 125 interrupt system 8.4 external interrupts the external interrupts 0 and 1 can be programmed to be level-activated or negative-transition activated by setting or clearing bit it0 or it1, respectively, in register tcon ( see figure 8-4 ). lf itx = 0 (x = 0 or 1), external interrupt x is triggered by a detected low level at the intx pin. lf itx = 1, external interrupt x is negative edge-triggered. in this mode, if successive samples of the intx pin show a high in one cycle and a low in the next cycle, interrupt request flag lex in tcon is set. flag bit lex then requests the interrupt. lf the external interrupt 0 or 1 is level-activated, the external source has to hold the request active until the requested interrupt is actually generated. then it has to deactivate the request before the interrupt service routine is completed, or else another interrupt will be generated. the external interrupts 2 and 3 can be programmed to be negative or positive transition-activated by setting or clearing bit i2fr or i3fr in register t2con ( see figure 8-5 ). lf ixfr = 0 (x = 2 or 3), external interrupt x is negative transition-activated. lf ixfr = 1, external interrupt is triggered by a positive transition. the external interrupts 4, 5, and 6 are activated by a positive transition. the external timer 2 reload trigger interrupt request flag exf2 will be activated by a negative transition at pin p1.5/t2ex but only if bit exen2 is set. since the external interrupt pins (int2 to int6) are sampled once in each machine cycle, an input high or low should be held for at least 12 oscillator periods to ensure sampling. lf the external interrupt is transition-activated, the external source has to hold the request pin low (high for int2 and int3 , if it is programmed to be negative transition-active) for at least one cycle, and then hold it high (low) for at least one cycle to ensure that the transition is recognized so that the corresponding interrupt request flag will be set ( see figure 8-10 ). the external interrupt request flags will automatically be cleared by the cpu when the service routine is called.
semiconductor group 126 interrupt system figure 8-10 external interrupt detection 8.5 response time lf an external interrupt is recognized, its corresponding request flag is set at s5p2 in every machine cycle. the value is not polled by the circuitry until the next machine cycle. lf the request is active and conditions are right for it to be acknowledged, a hardware subroutine call to the requested service routine will be the next instruction to be executed. the call itself takes two cycles. thus a minimum of three complete machine cycles will elapse between activation and external interrupt request and the beginning of execution of the first instruction of the service routine. a longer response time would be obtained if the request was blocked by one of the three previously listed conditions. lf an interrupt of equal or higher priority is already in progress, the additional wait time obviously depends on the nature of the other interrupts service routine. lf the instruction in progress is not in its final cycle, the additional wait time cannot be more than 3 cycles since the longest instructions (mul and div) are only 4 cycles long; and, if the instruction in progress is reti or a write access to registers ien0, ien1 or ip0, ip1, the additional wait time cannot be more than 5 cycles (a maximum of one more cycle to complete the instruction in progress, plus 4 cycles to complete the next instruction, if the instruction is mul or div). thus, in a single interrupt system, the response time is always more than 3 cycles and less than 9 cycles.
semiconductor group 127 instruction set 9 instruction set the sab 80(c)515/80(c)535 instruction set includes 111 instructions, 49 of which are single-byte, 45 two-byte and 17 three-byte instructions. the instruction opcode format consists of a function mnemonic followed by a destination, source operand field. this field specifies the data type and addressing method(s) to be used. like all other members of the 8051-family, the sab 80(c)515/80(c)535 can be programmed with the same instruction set common to the basic member, the sab 8051. thus, the sab 80(c)515/80(c)535 is 100% software compatible to the sab 8051 and may be programmed with 8051 assembler or high-level languages. 9.1 addressing modes the sab 80(c)515/80(c)535 uses five addressing modes: C register Cdirect C immediate C register indirect C base register plus index-register indirect table 9-1 summarizes the memory spaces which may be accessed by each of the addressing modes. register addressing register addressing accesses the eight working registers (r0 - r7) of the selected register bank. the least significant bit of the instruction opcode indicates which register is to be used. acc, b, dptr and cy, the boolean processor accumulator, can also be addressed as registers. direct addressing direct addressing is the only method of accessing the special function registers. the lower 128 bytes of internal ram are also directly addressable. immediate addressing immediate addressing allows constants to be part of the instruction in program memory.
semiconductor group 128 instruction set table 9-1 addressing modes and associated memory spaces register indirect addressing register indirect addressing uses the contents of either r0 or r1 (in the selected register bank) as a pointer to locations in a 256-byte block: the 256 bytes of internal ram or the lower 256 bytes of external data memory. note that the special function registers are not accessible by this method. the upper half of the internal ram can be accessed by indirect addressing only. access to the full 64 kbytes of external data memory address space is accomplished by using the 16-bit data pointer. execution of push and pop instructions also uses register indirect addressing. the stack may reside anywhere in the internal ram. base register plus index register addressing base register plus index register addressing allows a byte to be accessed from program memory via an indirect move from the location whose address is the sum of a base register (dptr or pc) and index register, acc. this mode facilitates look-up table accesses. boolean processor the boolean processor is a bit processor integrated into the sab 80(c)515/80(c)535. it has its own instruction set, accumulator (the carry flag), bit-addressable ram and l/o. addressing modes associated memory spaces register addressing r0 through r7 of selected register bank, acc, b, cy (bit), dptr direct addressing lower 128 bytes of internal ram, special function registers immediate addressing program memory register indirect addressing internal ram (@r1, @r0, sp), external data memory (@r1, @r0, @dptr) base register plus index register addressing program memory (@dptr + a, @pc + a)
semiconductor group 129 instruction set the bit manipulation instructions allow: C set bit C clear bit C complement bit C jump if bit is set C jump if bit is not set C jump if bit is set and clear bit C move bit from / to carry addressable bits, or their complements, may be logically and-ed or or-ed with the contents of the carry flag. the result is returned to the carry register. 9.2 introduction to the instruction set the instruction set is divided into four functional groups: C data transfer C arithmetic C logic C control transfer 9.2.1 data transfer data operations are divided into three classes: C general-purpose C accumulator-specific C address-object none of these operations affects the psw flag settings except a pop or mov directly to the psw.
semiconductor group 130 instruction set general-purpose transfers C mov performs a bit or byte transfer from the source operand to the destination operand. C push increments the sp register and then transfers a byte from the source operand to the stack location currently addressed by sp. C pop transfers a byte operand from the stack location addressed by the sp to the destination operand and then decrements sp. accumulator-specific transfers C xch exchanges the byte source operand with register a (accumulator). C xchd exchanges the low-order nibble of the source operand byte with the low-order nibble of a. C movx performs a byte move between the external data memory and the accumulator. the external address can be specified by the dptr register (16 bit) or the r1 or r0 register (8 bit). C movc moves a byte from program memory to the accumulator. the operand in a is used as an index into a 256-byte table pointed to by the base register (dptr or pc). the byte operand accessed is transferred to the accumulator. address-object transfer C mov dptr, #data loads 16 bits of immediate data into a pair of destination registers, dph and dpl. 9.2.2 arithmetic the sab 80(c)515/80(c)535 has four basic mathematical operations. only 8-bit operations using unsigned arithmetic are supported directly. the overflow flag, however, permits the addition and subtraction operation to serve for both unsigned and signed binary integers. arithmetic can also be performed directly on packed bcd representations. addition C inc (increment) adds one to the source operand and puts the result in the operand. C add adds a to the source operand and returns the result to a. C addc (add with carry) adds a and the source operand, then adds one (1) if cy is set, and puts the result in a. C da (decimal-add-adjust for bcd addition) corrects the sum which results from the binary addition of two-digit decimal operands. the packed decimal sum formed by da is returned to a. cy is set if the bcd result is greater than 99; otherwise, it is cleared.
semiconductor group 131 instruction set subtraction C subb (subtract with borrow) subtracts the second source operand from the the first operand (the accumulator), subtracts one (1) if cy is set and returns the result to a. C dec (decrement) subtracts one (1) from the source operand and returns the result to the operand. multiplication C mul performs an unsigned multiplication of the a register, returning a double byte result. a receives the low-order byte, b receives the high-order byte. ov is cleared if the top half of the result is zero and is set if it is not zero. cy is cleared. ac is unaffected. division C div performs an unsigned division of the a register by the b register; it returns the integer quotient to the a register and returns the fractional remainder to the b register. division by zero leaves indeterminate data in registers a and b and sets ov; otherwise, ov is cleared. cy is cleared. ac remains unaffected. flags unless otherwise stated in the previous descriptions, the flags of psw are affected as follows: C cy is set if the operation causes a carry to or a borrow from the resulting high-order bit; otherwise cy is cleared. C ac is set if the operation results in a carry from the low-order four bits of the result (during addition), or a borrow from the high-order bits to the low-order bits (during subtraction); otherwise ac is cleared. C ov is set if the operation results in a carry to the high-order bit of the result but not a carry from the bit, or vice versa; otherwise ov is cleared. ov is used in twos-complement arithmetic, because it is set when the signal result cannot be represented in 8 bits. C p is set if the modulo-2 sum of the eight bits in the accumulator is 1 (odd parity); otherwise p is cleared (even parity). when a value is written to the psw register, the p bit remains unchanged, as it always reflects the parity of a.
semiconductor group 132 instruction set 9.2.3 logic the sab 80(c)515/80(c)535 performs basic logic operations on both bit and byte operands. single-operand operations C clr sets a or any directly addressable bit to zero (0). C setb sets any directly bit-addressable bit to one (1). C cpl is used to complement the contents of the a register without affecting any flag, or any directly addressable bit location. C rl, rlc, rr, rrc, swap are the five operations that can be performed on a. rl, rotate left, rr, rotate right, rlc, rotate left through carry, rrc, rotate right through carry, and swap, rotate left four. for rlc and rrc the cy flag becomes equal to the last bit rotated out. swap rotates a left four places to exchange bits 3 through 0 with bits 7 through 4. two-operand operations C anl performs bitwise logical and of two operands (for both bit and byte operands) and returns the result to the location of the first operand. C orl performs bitwise logical or of two source operands (for both bit and byte operands) and returns the result to the location of the first operand. C xrl performs logical exclusive or of two source operands (byte operands) and returns the result to the location of the first operand. 9.2.4 control transfer there are three classes of control transfer operations: unconditional calls, returns, jumps, conditional jumps, and interrupts. all control transfer operations, some upon a specific condition, cause the program execution to continue a non-sequential location in program memory.
semiconductor group 133 instruction set unconditional calls, returns and jumps unconditional calls, returns and jumps transfer control from the current value of the program counter to the target address. both direct and indirect transfers are supported. C acall and lcall push the address of the next instruction onto the stack and then transfer control to the target address. acall is a 2-byte instruction used when the target address is in the current 2k page. lcall is a 3-byte instruction that addresses the full 64k program space. in acall, immediate data (i.e. an 11-bit address field) is concatenated to the five most significant bits of the pc (which is pointing to the next instruction). if acall is in the last 2 bytes of a 2k page then the call will be made to the next page since the pc will have been incremented to the next instruction prior to execution. C ret transfers control to the return address saved on the stack by a previous call operation and decrements the sp register by two (2) to adjust the sp for the popped address. C ajmp, ljmp and sjmp transfer control to the target operand. the operation of ajmp and ljmp are analogous to acall and lcall. the sjmp (short jump) instruction provides for transfers within a 256-byte range centered about the starting address of the next instruction (C 128 to + 127). C jmp @a + dptr performs a jump relative to the dptr register. the operand in a is used as the offset (0 - 255) to the address in the dptr register. thus, the effective destination for a jump can be anywhere in the program memory space. conditional jumps conditional jumps perform a jump contingent upon a specific condition. the destination will be within a 256-byte range centered about the starting address of the next instruction (C 128 to + 127). C jz performs a jump if the accumulator is zero. C jnz performs a jump if the accumulator is not zero. C jc performs a jump if the carry flag is set. C jnc performs a jump if the carry flag is not set. C jb performs a jump if the directly addressed bit is set. C jnb performs a jump if the directly addressed bit is not set. C jbc performs a jump if the directly addressed bit is set and then clears the directly addressed bit. C cjne compares the first operand to the second operand and performs a jump if they are not equal. cy is set if the first operand is less than the second operand; otherwise it is cleared. comparisons can be made between a and directly addressable bytes in internal data memory or an immediate value and either a, a register in the selected register bank, or a register indirectly addressable byte of the internal ram. C djnz decrements the source operand and returns the result to the operand. a jump is performed if the result is not zero. the source operand of the djnz instruction may be any directly addressable byte in the internal data memory. either direct or register addressing may be used to address the source operand. interrupt returns C reti transfers control as ret does, but additionally enables interrupts of the current priority level.
semiconductor group 134 instruction set 9.3 instruction definitions all 111 instructions of the sab 80(c)515/80(c)535 can essentially be condensed to 54 basic operations, in the following alphabetically ordered according to the operation mnemonic section. a brief example of how the instruction might be used is given as well as its effect on the psw flags. the number of bytes and machine cycles required, the binary machine language encoding, and a symbolic description or restatement of the function is also provided. note: only the carry, auxiliary carry, and overflow flags are discussed. the parity bit is computed after every instruction cycle that alters the accumulator. similarily, instructions which alter directly addressed registers could affect the other status flags if the instruction is applied to the psw. status flags can also be modified by bit manipulation. instruction flag instruction flag cy ov ac cy ov ac add x x x setb c 1 addc xxxclr c 0 subb xxxcpl c x mul 0 x anl c,bit x div 0 x anl c,/bit x da x orl c,bit x rrc x orl c,/bit x rlc x mov c,bit x cjne x
semiconductor group 135 instruction set notes on data addressing modes rn - working register r0-r7 direct - 128 internal ram locations, any l/o port, control or status register @ri - indirect internal or external ram location addressed by register r0 or r1 #data - 8-bit constant included in instruction #data 16 - 16-bit constant included as bytes 2 and 3 of instruction bit - 128 software flags, any bitaddressable l/o pin, control or status bit a - accumulator notes on program addressing modes addr16 - destination address for lcall and ljmp may be anywhere within the 64-kbyte program memory address space. addr11 - destination address for acall and ajmp will be within the same 2-kbyte page of program memory as the first byte of the following instruction. rel - sjmp and all conditional jumps include an 8 bit offset byte. range is + 127/C 128 bytes relative to the first byte of the following instruction. all mnemonics copyrighted: ? intel corporation 1980
semiconductor group 136 instruction set acall addr11 function: absolute call description: acall unconditionally calls a subroutine located at the indicated address. the instruction increments the pc twice to obtain the address of the following instruction, then pushes the 16-bit result onto the stack (low-order byte first) and increments the stack pointer twice. the destination address is obtained by successively concatenating the five high-order bits of the incremented pc, op code bits 7-5, and the second byte of the instruction. the subroutine called must therefore start within the same 2k block of program memory as the first byte of the instruction following acall. no flags are affected. example: initially sp equals 07 h . the label subrtn is at program memory location 0345 h . after executing the instruction acall subrtn at location 0123 h , sp will contain 09 h , internal ram location 08 h and 09 h will contain 25 h and 01 h , respectively, and the pc will contain 0345 h . operation: acall (pc) ? (pc) + 2 (sp) ? (sp) + 1 ((sp)) ? (pc7-0) (sp) ? (sp) + 1 ((sp)) ? (pc15-8) (pc10-0) ? page address bytes: 2 cycles: 2 encoding: a10 a9 a8 1 0 0 0 1 a7 a6 a5 a4 a3 a2 a1 a0
semiconductor group 137 instruction set add a, function: add description: add adds the byte variable indicated to the accumulator, leaving the result in the accumulator. the carry and auxiliary carry flags are set, respectively, if there is a carry out of bit 7 or bit 3, and cleared otherwise. when adding unsigned integers, the carry flag indicates an overflow occurred. ov is set if there is a carry out of bit 6 but not out of bit 7, or a carry out of bit 7 but not out of bit 6; otherwise ov is cleared. when adding signed integers, ov indicates a negative number produced as the sum of two positive operands, or a positive sum from two negative operands. four source operand addressing modes are allowed: register, direct, register- indirect, or immediate. example: the accumulator holds 0c3 h (11000011 b ) and register 0 holds 0aa h (10101010 b ). the instruction add a,r0 will leave 6d h (01101101 b ) in the accumulator with the ac flag cleared and both the carry flag and ov set to 1. add a,rn operation: add (a) ? (a) + (rn) bytes: 1 cycles: 1 add a,direct operation: add (a) ? (a) + (direct) bytes: 2 cycles: 1 encoding: 0 0 1 0 1 r r r encoding: 0 0 1 0 0 1 0 1 direct address
semiconductor group 138 instruction set add a, @ri operation: add (a) ? (a) + ((ri)) bytes: 1 cycles: 1 add a, #data operation: add (a) ? (a) + #data bytes: 2 cycles: 1 encoding: 0 0 1 0 0 1 1 i encoding: 0 0 1 0 0 1 0 0 immediate data
semiconductor group 139 instruction set addc a, < src-byte> function: add with carry description: addc simultaneously adds the byte variable indicated, the carry flag and the accumulator contents, leaving the result in the accumulator. the carry and auxiliary carry flags are set, respectively, if there is a carry out of bit 7 or bit 3, and cleared otherwise. when adding unsigned integers, the carry flag indicates an overflow occurred. ov is set if there is a carry out of bit 6 but not out of bit 7, or a carry out of bit 7 but not out of bit 6; otherwise ov is cleared. when adding signed integers, ov indicates a negative number produced as the sum of two positive operands or a positive sum from two negative operands. four source operand addressing modes are allowed: register, direct, register- indirect, or immediate. example: the accumulator holds 0c3 h (11000011b) and register 0 holds 0aa h (10101010b) with the carry flag set. the instruction addc a,r0 will leave 6e h (01101110b) in the accumulator with ac cleared and both the carry flag and ov set to 1. addc a,rn operation: addc (a) ? (a) + (c) + (rn) bytes: 1 cycles: 1 addc a,direct operation: addc (a) ? (a) + (c) + (direct) bytes: 2 cycles: 1 encoding: 0 0 1 1 1 r r r encoding: 0 0 1 1 0 1 0 1 direct address
semiconductor group 140 instruction set addc a, @ri operation: addc (a) ? (a) + (c) + ((ri)) bytes: 1 cycles: 1 addc a, #data operation: addc (a) ? (a) + (c) + #data bytes: 2 cycles: 1 encoding: 0 0 1 1 0 1 1 i encoding: 0 0 1 1 0 1 0 0 immediate data
semiconductor group 141 instruction set ajmp addr11 function: absolute jump description: ajmp transfers program execution to the indicated address, which is formed at run- time by concatenating the high-order five bits of the pc ( after incrementing the pc twice), op code bits 7-5, and the second byte of the instruction. the destination must therefore be within the same 2k block of program memory as the first byte of the instruction following ajmp. example: the label jmpadr is at program memory location 0123 h . the instruction ajmp jmpadr is at location 0345 h and will load the pc with 0123 h . operation: ajm p (pc) ? (pc) + 2 (pc10-0) ? page address bytes: 2 cycles: 2 encoding: a10 a9 a8 0 0 0 0 1 a7 a6 a5 a4 a3 a2 a1 a0
semiconductor group 142 instruction set anl , function: logical and for byte variables description: anl performs the bitwise logical and operation between the variables indicated and stores the results in the destination variable. no flags are affected. the two operands allow six addressing mode combinations. when the destination is a accumulator, the source can use register, direct, register-indirect, or immediate addressing; when the destination is a direct address, the source can be the accumulator or immediate data. note: when this instruction is used to modify an output port, the value used as the original port data will be read from the output data latch, not the input pins. example: if the accumulator holds 0c3 h (11000011b) and register 0 holds 0aa h (10101010b) then the instruction anl a,r0 will leave 81 h (10000001b) in the accumulator. when the destination is a directly addressed byte, this instruction will clear combinations of bits in any ram location or hardware register. the mask byte determining the pattern of bits to be cleared would either be a constant contained in the instruction or a value computed in the accumulator at run-time. the instruction anl p1, #01110011b will clear bits 7, 3, and 2 of output port 1. anl a,rn operation: anl (a) ? (a) (rn) bytes: 1 cycles: 1 encoding: 0 1 0 1 1 r r r
semiconductor group 143 instruction set anl a,direct operation: anl (a) ? (a) (direct) bytes: 2 cycles: 1 anl a, @ri operation: anl (a) ? (a) ((ri)) bytes: 1 cycles: 1 anl a, #data operation: anl (a) ? (a) #data bytes: 2 cycles: 1 anl direct,a operation: anl (direct) ? (direct) (a) bytes: 2 cycles: 1 encoding: 0 1 0 1 0 1 0 1 direct address encoding: 0 1 0 1 0 1 1 i encoding: 0 1 0 1 0 1 0 0 immediate data encoding: 0 1 0 1 0 1 0 1 direct address
semiconductor group 144 instruction set anl direct, #data operation: anl (direct) ? (direct) #data bytes: 3 cycles: 2 encoding: 0 1 0 1 0 0 1 1 direct address immediate data
semiconductor group 145 instruction set anl c, function: logical and for bit variables description: if the boolean value of the source bit is a logic 0 then clear the carry flag; otherwise leave the carry flag in its current state. a slash (/ preceding the operand in the assembly language indicates that the logical complement of the addressed bit is used as the source value, but the source bit itself is not affected . no other flags are affected. only direct bit addressing is allowed for the source operand. example: set the carry flag if, and only if, p1.0 = 1, acc.7 = 1, and ov = 0: mov c,p1.0 ; load carry with input pin state anl c,acc.7 ; and carry with accumulator bit 7 anl c,/ov ; and with inverse of overflow flag anl c,bit operation: anl (c) ? (c) (bit) bytes: 2 cycles: 2 anl c,/bit operation: anl (c) ? (c) ? (bit) bytes: 2 cycles: 2 encoding: 1 0 0 0 0 0 1 0 bit address encoding: 1 0 1 1 0 0 0 0 bit address
semiconductor group 146 instruction set cjne , < src-byte >, rel function: compare and jump if not equal description: cjne compares the magnitudes of the tirst two operands, and branches if their values are not equal. the branch destination is computed by adding the signed relative displacement in the last instruction byte to the pc, after incrementing the pc to the start of the next instruction. the carry flag is set if the unsigned integer value of is less than the unsigned integer value of ; otherwise, the carry is cleared. neither operand is affected. the first two operands allow four addressing mode combinations: the accumulator may be compared with any directly addressed byte or immediate data, and any indirect ram location or working register can be compared with an immediate constant. example: the accumulator contains 34 h . register 7 contains 56 h . the first instruction in the sequence cjne r7, # 60 h , not_eq ; . . . . . . . . ; r7 = 60 h not_eq jc req_low ; if r7 < 60 h ; . . . . . . . . ; r7 > 60 h sets the carry flag and branches to the instruction at label not_eq. by testing the carry flag, this instruction determines whether r7 is greater or less than 60 h . if the data being presented to port 1 is also 34 h , then the instruction wait: cjne a,p1,wait clears the carry flag and continues with the next instruction in sequence, since the accumulator does equal the data read from p1. (if some other value was input on p1, the program will loop at this point until the p1 data changes to 34 h ).
semiconductor group 147 instruction set cjne a,direct,rel operation: (pc) ? (pc) + 3 if (a) < > (direct) then (pc) ? (pc) + relative offset if (a) < (direct) then (c) ? 1 else (c) ? 0 bytes: 3 cycles: 2 cjne a, #data,rel operation: (pc) ? (pc) + 3 if (a) < > data then (pc) ? (pc) + relative offset if (a) ? data then (c) ? 1 else (c) ? 0 bytes: 3 cycles: 2 cjne rn, #data, rel operation: (pc) ? (pc) + 3 if (rn) < > data then (pc) ? (pc) + relative offset if (rn) < data then (c) ? 1 else (c) ? 0 bytes: 3 cycles: 2 encoding: 1 0 1 1 0 1 0 1 direct address rel. address encoding: 1 0 1 1 0 1 0 0 immediate data rel. address encoding: 1 0 1 1 1 r r r immediate data rel. address
semiconductor group 148 instruction set cjne @ri, #data,rel operation: (pc) ? (pc) + 3 if ((ri)) < > data then (pc) ? (pc) + relative offset if ((ri)) < data then (c) ? 1 else (c) ? 0 bytes: 3 cycles: 2 encoding: 1 0 1 1 0 1 1 i immediate data rel. address
semiconductor group 149 instruction set clr a function: clear accumulator description: the accumulator is cleared (all bits set to zero). no flags are affected. example: the accumulator contains 5c h (01011100b). the instruction clr a will leave the accumulator set to 00 h (00000000b). operation: clr (a) ? 0 bytes: 1 cycles: 1 encoding: 1 1 1 0 0 1 0 0
semiconductor group 150 instruction set clr bit function: clear bit description: the indicated bit is cleared (reset to zero). no other flags are affected. clr can operate on the carry flag or any directly addressable bit. example: port 1 has previously been written with 5d h (01011101b). the instruction clr p1.2 will leave the port set to 59 h (01011001b). clr c operation: clr (c) ? 0 bytes: 1 cycles: 1 clr bit operation: clr (bit) ? 0 bytes: 2 cycles: 1 encoding: 1 1 0 0 0 0 1 1 encoding: 1 1 0 0 0 0 1 0 bit address
semiconductor group 151 instruction set cpl a function: complement accumulator description: each bit of the accumulator is logically complemented (ones complement). bits which previously contained a one are changed to zero and vice versa. no flags are affected. example: the accumulator contains 5c h (01011100b). the instruction cpl a will leave the accumulator set to 0a3 h (10100011 b). operation: cpl (a) ?? (a) bytes: 1 cycles: 1 encoding: 1 1 1 1 0 1 0 0
semiconductor group 152 instruction set cpl bit function: complement bit description: the bit variable specified is complemented. a bit which had been a one is changed to zero and vice versa. no other flags are affected. cpl can operate on the carry or any directly addressable bit. note: when this instruction is used to modify an output pin, the value used as the original data will be read from the output data latch, not the input pin. example: port 1 has previously been written with 5d h (01011101 b ). the instruction sequence cpl p1.1 cpl p1.2 will leave the port set to 5b h (01011011 b ). cpl c operation: cpl (c) ?? (c) bytes: 1 cycles: 1 cpl bit operation: cpl (bit) ?? (bit) bytes: 2 cycles: 1 encoding: 1 0 1 1 0 0 1 1 encoding: 1 0 1 1 0 0 1 0 bit address
semiconductor group 153 instruction set da a function: decimal adjust accumulator for addition description: da a adjusts the eight-bit value in the accumulator resulting from the earlier addition of two variables (each in packed bcd format), producing two four-bit digits. any add or addc instruction may have been used to perform the addition. if accumulator bits 3-0 are greater than nine (xxxx1010-xxxx1111), or if the ac flag is one, six is added to the accumulator producing the proper bcd digit in the low- order nibble. this internal addition would set the carry flag if a carry-out of the low- order four-bit field propagated through all high-order bits, but it would not clear the carry flag otherwise. if the carry flag is now set, or if the four high-order bits now exceed nine (1010xxxx- 1111xxxx), these high-order bits are incremented by six, producing the proper bcd digit in the high-order nibble. again, this would set the carry flag if there was a carry- out of the high-order bits, but wouldnt clear the carry. the carry flag thus indicates if the sum of the original two bcd variables is greater than 100, allowing multiple precision decimal addition. ov is not affected. all of this occurs during the one instruction cycle. essentially; this instruction performs the decimal conversion by adding 00 h , 06 h , 60 h , or 66 h to the accumulator, depending on initial accumulator and psw conditions. note: da a cannot simply convert a hexadecimal number in the accumulator to bcd notation, nor does da a apply to decimal subtraction. example: the accumulator holds the value 56 h (01010110b) representing the packed bcd digits of the decimal number 56. register 3 contains the value 67 h (01100111b) representing the packed bcd digits of the decimal number 67. the carry flag is set. the instruction sequence addc a,r3 da a will first perform a standard twos-complement binary addition, resulting in the value 0be h (10111110b) in the accumulator. the carry and auxiliary carry flags will be cleared. the decimal adjust instruction will then alter the accumulator to the value 24 h (00100100b), indicating the packed bcd digits of the decimal number 24, the low- order two digits of the decimal sum of 56, 67, and the carry-in. the carry flag will be set by the decimal adjust instruction, indicating that a decimal overflow occurred. the true sum 56, 67, and 1 is 124.
semiconductor group 154 instruction set bcd variables can be incremented or decremented by adding 01 h or 99 h . if the accumulator initially holds 30 h (representing the digits of 30 decimal), then the instruction sequence add a, #99 h da a will leave the carry set and 29 h in the accumulator, since 30 + 99 = 129. the low- order byte of the sum can be interpreted to mean 30 C 1 = 29. operation: da contents of accumulator are bcd if [[(a3-0) > 9] [(ac) = 1]] then (a3-0) ? (a3-0) + 6 and if [[(a7-4) > 9] [(c) = 1]] then (a7-4) ? (a7-4) + 6 bytes: 1 cycles: 1 encoding: 1 1 0 1 0 1 0 0
semiconductor group 155 instruction set dec byte function: decrement description: the variable indicated is decremented by 1. an original value of 00 h will underflow to 0ff h . no flags are affected. four operand addressing modes are allowed: accumulator, register, direct, or register-indirect. note: when this instruction is used to modify an output port, the value used as the original port data will be read from the output data latch, not the input pins. example: register 0 contains 7f h (01111111b). internal ram locations 7e h and 7f h contain 00 h and 40 h , respectively. the instruction sequence dec @r0 dec r0 dec @r0 will leave register 0 set to 7e h and internal ram locations 7e h and 7f h set to 0ff h and 3f h . dec a operation: dec (a) ? (a) C 1 bytes: 1 cycles: 1 dec rn operation: dec (rn) ? (rn) C 1 bytes: 1 cycles: 1 encoding: 0 0 0 1 0 1 0 0 encoding: 0 0 0 1 1 r r r
semiconductor group 156 instruction set dec direct operation: dec (direct) ? (direct) C 1 bytes: 2 cycles: 1 dec @ri operation: dec ((ri)) ? ((ri)) C 1 bytes: 1 cycles: 1 encoding: 0 0 0 1 0 1 0 1 direct address encoding: 0 0 0 1 0 1 1 i
semiconductor group 157 instruction set instruction set div ab function: divide description: div ab divides the unsigned eight-bit integer in the accumulator by the unsigned eight-bit integer in register b. the accumulator receives the integer part of the quotient; register b receives the integer remainder. the carry and ov flags will be cleared. exception: if b had originally contained 00 h , the values returned in the accumulator and b register will be undefined and the overflow flag will be set. the carry flag is cleared in any case. example: the accumulator contains 251 (0fb h or 11111011b) and b contains 18 (12 h or 00010010b). the instruction div ab will leave 13 in the accumulator (0d h or 00001101 b) and the value 17 (11 h or 00010001b) in b, since 251 = (13x18) + 17. carry and ov will both be cleared. operation: div (a15-8) (b7-0) bytes: 1 cycles: 4 encoding: 1 0 0 0 0 1 0 0 ? (a) / (b)
semiconductor group 158 instruction set djnz , < rel-addr> function: decrement and jump if not zero description: djnz decrements the location indicated by 1, and branches to the address indicated by the second operand if the resulting value is not zero. an original value of 00 h will underflow to 0ff h . no flags are affected. the branch destination would be computed by adding the signed relative-displacement value in the last instruction byte to the pc, after incrementing the pc to the first byte of the following instruction. the location decremented may be a register or directly addressed byte. note: when this instruction is used to modify an output port, the value used as the original port data will be read from the output data latch, not the input pins. example: internal ram locations 40 h , 50 h , and 60 h contain the values, 01 h , 70 h , and 15 h , respectively. the instruction sequence djnz 40 h ,label_1 djnz 50 h ,label_2 djnz 60 h ,label_3 will cause a jump to the instruction at label label_2 with the values 00 h , 6f h , and 15 h in the three ram locations. the first jump was not taken because the result was zero. this instruction provides a simple way of executing a program loop a given number of times, or for adding a moderate time delay (from 2 to 512 machine cycles) with a single instruction. the instruction sequence mov r2, #8 toggle: cpl p1.7 djnz r2,toggle will toggle p1.7 eight times, causing four output pulses to appear at bit 7 of output port 1. each pulse will last three machine cycles; two for djnz and one to alter the pin.
semiconductor group 159 instruction set djnz rn,rel operation: djnz (pc) ? (pc) + 2 (rn) ? (rn) C 1 if (rn) > 0 or (rn) < 0 then (pc) ? (pc) + rel bytes: 2 cycles: 2 djnz direct,rel operation: djnz (pc) ? (pc) + 2 (direct) ? (direct) C 1 if (direct) > 0 or (direct) < 0 then (pc) ? (pc) + rel bytes: 3 cycles: 2 encoding: 1 1 0 1 1 r r r rel. address encoding: 1 1 0 1 0 1 0 1 direct address rel. address
semiconductor group 160 instruction set inc function: increment description: inc increments the indicated variable by 1. an original value of 0ff h will overflow to 00 h . no flags are affected. three addressing modes are allowed: register, direct, or register-indirect. note: when this instruction is used to modify an output port, the value used as the original port data will be read from the output data latch, not the input pins. example: register 0 contains 7e h (01111110b). internal ram locations 7e h and 7f h contain 0ff h and 40 h , respectively. the instruction sequence inc @r0 inc r0 inc @r0 will leave register 0 set to 7f h and internal ram locations 7e h and 7f h holding (respectively) 00 h and 41 h . inc a operation: inc (a) ? (a) + 1 bytes: 1 cycles: 1 inc rn operation: inc (rn) ? (rn) + 1 bytes: 1 cycles: 1 encoding: 0 0 0 0 0 1 0 0 encoding: 0 0 0 0 1 r r r
semiconductor group 161 instruction set inc direct operation: inc (direct) ? (direct) + 1 bytes: 2 cycles: 1 inc @ri operation: inc ((ri)) ? ((ri)) + 1 bytes: 1 cycles: 1 encoding: 0 0 0 0 0 1 0 1 direct address encoding: 0 0 0 0 0 1 1 i
semiconductor group 162 instruction set inc dptr function: increment data pointer description: increment the 16-bit data pointer by 1. a 16-bit increment (modulo 2 16 ) is performed; an overflow of the low-order byte of the data pointer (dpl) from 0ff h to 00 h will increment the high-order byte (dph). no flags are affected. this is the only 16-bit register which can be incremented. example: registers dph and dpl contain 12 h and 0fe h , respectively. the instruction sequence inc dptr inc dptr inc dptr will change dph and dpl to 13 h and 01 h . operation: inc (dptr) ? (dptr) + 1 bytes: 1 cycles: 2 encoding: 1 0 1 0 0 0 1 1
semiconductor group 163 instruction set jb bit,rel function: jump if bit is set description: if the indicated bit is a one, jump to the address indicated; otherwise proceed with the next instruction. the branch destination is computed by adding the signed relative-displacement in the third instruction byte to the pc, after incrementing the pc to the first byte of the next instruction. the bit tested is not modified. no flags are affected. example: the data present at input port 1 is 11001010b. the accumulator holds 56 (01010110b). the instruction sequence jb p1.2,label1 jb acc.2,label2 will cause program execution to branch to the instruction at label label2. operation: jb (pc) ? (pc) + 3 if (bit) = 1 then (pc) ? (pc) + rel bytes: 3 cycles: 2 encoding: 0 0 1 0 0 0 0 0 bit address rel. address
semiconductor group 164 instruction set jbc bit,rel function: jump if bit is set and clear bit description: if the indicated bit is one, branch to the address indicated; otherwise proceed with the next instruction. in either case, clear the designated bit. the branch destination is computed by adding the signed relative displacement in the third instruction byte to the pc, after incrementing the pc to the first byte of the next instruction. no flags are affected. note: when this instruction is used to test an output pin, the value used as the original data will be read from the output data latch, not the input pin. example: the accumulator holds 56 h (01010110b). the instruction sequence jbc acc.3,label1 jbc acc.2,label2 will cause program execution to continue at the instruction identified by the label label2, with the accumulator modified to 52 h (01010010b). operation: jbc (pc) ? (pc) + 3 if (bit) = 1 then (bit) ? 0 (pc) ? (pc) + rel bytes: 3 cycles: 2 encoding: 0 0 0 1 0 0 0 0 bit address rel. address
semiconductor group 165 instruction set jc rel function: jump if carry is set description: if the carry flag is set, branch to the address indicated; otherwise proceed with the next instruction. the branch destination is computed by adding the signed relative- displacement in the second instruction byte to the pc, after incrementing the pc twice. no flags are affected. example: the carry flag is cleared. the instruction sequence jc label1 cpl c jc label2 will set the carry and cause program execution to continue at the instruction identified by the label label2. operation: jc (pc) ? (pc) + 2 if (c) = 1 then (pc) ? (pc) + rel bytes: 2 cycles: 2 encoding: 0 1 0 0 0 0 0 0 rel. address
semiconductor group 166 instruction set jmp @a + dptr function: jump indirect description: add the eight-bit unsigned contents of the accumulator with the sixteen-bit data pointer, and load the resulting sum to the program counter. this will be the address for subsequent instruction fetches. sixteen-bit addition is performed (modulo 2 16 ): a carry-out from the low-order eight bits propagates through the higher-order bits. neither the accumulator nor the data pointer is altered. no flags are affected. example: an even number from 0 to 6 is in the accumulator. the following sequence of instructions will branch to one of four ajmp instructions in a jump table starting at jmp_tbl: mov dptr, #jmp_tbl jmp @a + dptr jmp_tbl: ajmp label0 ajmp label1 ajmp label2 ajmp label3 if the accumulator equals 04 h when starting this sequence, execution will jump to label label2. remember that ajmp is a two-byte instruction, so the jump instructions start at every other address. operation: jmp (pc) ? (a) + (dptr) bytes: 1 cycles: 2 encoding: 0 1 1 1 0 0 1 1
semiconductor group 167 instruction set jnb bit,rel function: jump if bit is not set description: if the indicated bit is a zero, branch to the indicated address; otherwise proceed with the next instruction. the branch destination is computed by adding the signed relative-displacement in the third instruction byte to the pc, after incrementing the pc to the first byte of the next instruction. the bit tested is not modified. no flags are affected. example: the data present at input port 1 is 11001010b. the accumulator holds 56 h (01010110b). the instruction sequence jnb p1.3,label1 jnb acc.3,label2 will cause program execution to continue at the instruction at label label2. operation: jnb (pc) ? (pc) + 3 if (bit) = 0 then (pc) ? (pc) + rel. bytes: 3 cycles: 2 encoding: 0 0 1 1 0 0 0 0 bit address rel. address
semiconductor group 168 instruction set jnc rel function: jump if carry is not set description: if the carry flag is a zero, branch to the address indicated; otherwise proceed with the next instruction. the branch destination is computed by adding the signed relative-displacement in the second instruction byte to the pc, after incrementing the pc twice to point to the next instruction. the carry flag is not modified. example: the carry flag is set. the instruction sequence jnc label1 cpl c jnc label2 will clear the carry and cause program execution to continue at the instruction identified by the label label2. operation: jnc (pc) ? (pc) + 2 if (c) = 0 then (pc) ? (pc) + rel bytes: 2 cycles: 2 encoding: 0 1 0 1 0 0 0 0 rel. address
semiconductor group 169 instruction set jnz rel function: jump if accumulator is not zero description: if any bit of the accumulator is a one, branch to the indicated address; otherwise proceed with the next instruction. the branch destination is computed by adding the signed relative-displacement in the second instruction byte to the pc, after incrementing the pc twice. the accumulator is not modified. no flags are affected. example: the accumulator originally holds 00 h . the instruction sequence jnz label1 inc a jnz label2 will set the accumulator to 01 h and continue at label label2. operation: jnz (pc) ? (pc) + 2 if (a) 1 0 then (pc) ? (pc) + rel. bytes: 2 cycles: 2 encoding: 0 1 1 1 0 0 0 0 rel. address
semiconductor group 170 instruction set jz rel function: jump if accumulator is zero description: if all bits of the accumulator are zero, branch to the address indicated; otherwise proceed with the next instruction. the branch destination is computed by adding the signed relative-displacement in the second instruction byte to the pc, after incrementing the pc twice. the accumulator is not modified. no flags are affected. example: the accumulator originally contains 01 h . the instruction sequence jz label1 dec a jz label2 will change the accumulator to 00 h and cause program execution to continue at the instruction identified by the label label2. operation: jz (pc) ? (pc) + 2 if (a) = 0 then (pc) ? (pc) + rel bytes: 2 cycles: 2 encoding: 0 1 1 0 0 0 0 0 rel. address
semiconductor group 171 instruction set lcall addr16 function: long call description: lcall calls a subroutine located at the indicated address. the instruction adds three to the program counter to generate the address of the next instruction and then pushes the 16-bit result onto the stack (low byte first), incrementing the stack pointer by two. the high-order and low-order bytes of the pc are then loaded, respectively, with the second and third bytes of the lcall instruction. program execution continues with the instruction at this address. the subroutine may therefore begin anywhere in the full 64 kbyte program memory address space. no flags are affected. example: initially the stack pointer equals 07 h . the label subrtn is assigned to program memory location 1234 h . after executing the instruction lcall subrtn at location 0123 h , the stack pointer will contain 09 h , internal ram locations 08 h and 09 h will contain 26 h and 01 h , and the pc will contain 1234 h . operation: lcall (pc) ? (pc) + 3 (sp) ? (sp) + 1 ((sp)) ? (pc7-0) (sp) ? (sp) + 1 ((sp)) ? (pc15-8) (pc) ? addr15-0 bytes: 3 cycles: 2 encoding: 0 0 0 1 0 0 1 0 addr15 . . addr8 addr7 . . addr0
semiconductor group 172 instruction set ljmp addr16 function: long jump description: ljmp causes an unconditional branch to the indicated address, by loading the high- order and low-order bytes of the pc (respectively) with the second and third instruction bytes. the destination may therefore be anywhere in the full 64k program memory address space. no flags are affected. example: the label jmpadr is assigned to the instruction at program memory location 1234 h . the instruction ljmp jmpadr at location 0123 h will load the program counter with 1234 h . operation: ljmp (pc) ? addr15-0 bytes: 3 cycles: 2 encoding: 0 0 0 0 0 0 1 0 addr15 . . . addr8 addr7 . . . addr0
semiconductor group 173 instruction set mov , function: move byte variable description: the byte variable indicated by the second operand is copied into the location specified by the first operand. the source byte is not affected. no other register or flag is affected. this is by far the most flexible operation. fifteen combinations of source and destination addressing modes are allowed. example: internal ram location 30 h holds 40 h . the value of ram location 40 h is 10 h . the data present at input port 1 is 11001010b (0ca h ). mov r0, #30 h ; r0 < = 30 h mov a, @r0 ; a < = 40 h mov r1,a ; r1 < = 40 h mov b, @r1 ; b < = 10 h mov @r1,p1 ; ram (40 h ) < = 0ca h mov p2,p1 ; p2 < = 0ca h leaves the value 30 h in register 0, 40 h in both the accumulator and register 1, 10 h in register b, and 0ca h (11001010b) both in ram location 40 h and output on port 2. mov a,rn operation: mov (a) ? (rn) bytes: 1 cycles: 1 mov a,direct *) operation: mov (a) ? (direct) bytes: 2 cycles: 1 *) mov a,acc is not a valid instruction. encoding: 1 1 1 0 1 r r r encoding: 1 1 1 0 0 1 0 1 direct address
semiconductor group 174 instruction set mov a,@ri operation: mov (a) ? ((ri)) bytes: 1 cycles: 1 mov a, #data operation: mov (a) ? #data bytes: 2 cycles: 1 mov rn,a operation: mov (rn) ? (a) bytes: 1 cycles: 1 mov rn,direct operation: mov (rn) ? (direct) bytes: 2 cycles: 2 encoding: 1 1 1 0 0 1 1 i encoding: 0 1 1 1 0 1 0 0 immediate data encoding: 1 1 1 1 1 r r r encoding: 1 0 1 0 1 r r r direct address
semiconductor group 175 instruction set mov rn, #data operation: mov (rn) ? #data bytes: 2 cycles: 1 mov direct,a operation: mov (direct) ? (a) bytes: 2 cycles: 1 mov direct,rn operation: mov (direct) ? (rn) bytes: 2 cycles: 2 mov direct,direct operation: mov (direct) ? (direct) bytes: 3 cycles: 2 encoding: 0 1 1 1 1 r r r immediate data encoding: 1 1 1 1 0 1 0 1 direct address encoding: 1 0 0 0 1 r r r direct address encoding: 1 0 0 0 0 1 0 1 dir.addr. (src) dir.addr. (dest)
semiconductor group 176 instruction set mov direct, @ ri operation: mov (direct) ? ((ri)) bytes: 2 cycles: 2 mov direct, #data operation: mov (direct) ? #data bytes: 3 cycles: 2 mov @ ri,a operation: mov ((ri)) ? (a) bytes: 1 cycles: 1 mov @ ri,direct ooeration: mov ((ri)) ? (direct) bytes: 2 cycles: 2 encoding: 1 0 0 0 0 1 1 i direct address encoding: 0 1 1 1 0 1 0 1 direct address immediate data encoding: 1 1 1 1 0 1 1 i encoding: 1 0 1 0 0 1 1 i direct address
semiconductor group 177 instruction set mov @ ri,#data operation: mov ((ri)) ? #data bytes: 2 cycles: 1 encoding: 0 1 1 1 0 1 1 i immediate data
semiconductor group 178 instruction set mov , function: move bit data description: the boolean variable indicated by the second operand is copied into the location specified by the first operand. one of the operands must be the carry flag; the other may be any directly addressable bit. no other register or flag is affected. example: the carry flag is originally set. the data present at input port 3 is 11000101b. the data previously written to output port 1 is 35 h (00110101b). mov p1.3,c mov c,p3.3 mov p1.2,c will leave the carry cleared and change port 1 to 39 h (00111001 b). mov c,bit operation: mov (c) ? (bit) bytes: 2 cycles: 1 mov bit,c operation: mov (bit) ? (c) bytes: 2 cycles: 2 encoding: 1 0 1 0 0 0 1 0 bit address encoding: 1 0 0 1 0 0 1 0 bit address
semiconductor group 179 instruction set mov dptr, #data16 function: load data pointer with a 16-bit constant description: the data pointer is loaded with the 16-bit constant indicated. the 16 bit constant is loaded into the second and third bytes of the instruction. the second byte (dph) is the high-order byte, while the third byte (dpl) holds the low-order byte. no flags are affected. this is the only instruction which moves 16 bits of data at once. example: the instruction mov dptr, #1234 h will load the value 1234 h into the data pointer: dph will hold 12 h and dpl will hold 34 h . operation: mov (dptr) ? #data15-0 dph dpl ? #data15-8 #data7-0 bytes: 3 cycles: 2 encoding: 1 0 0 1 0 0 0 0 immed. data 15 . . . 8 immed. data 7 . . . 0
semiconductor group 180 instruction set movc a, @a + function: move code byte description: the movc instructions load the accumulator with a code byte, or constant from program memory. the address of the byte fetched is the sum of the original unsigned eight-bit accumulator contents and the contents of a sixteen-bit base register, which may be either the data pointer or the pc. in the latter case, the pc is incremented to the address of the following instruction before being added to the accumulator; otherwise the base register is not altered. sixteen-bit addition is performed so a carry-out from the low-order eight bits may propagate through higher-order bits. no flags are affected. example: a value between 0 and 3 is in the accumulator. the following instructions will translate the value in the accumulator to one of four values defined by the db (define byte) directive. rel_pc: inc a movc a, @a + pc ret db 66 h db 77 h db 88 h db 99 h if the subroutine is called with the accumulator equal to 01 h , it will return with 77 h in the accumulator. the inc a before the movc instruction is needed to get around the ret instruction above the table. if several bytes of code separated the movc from the table, the corresponding number would be added to the accumulator instead. movc a, @a + dptr operation: movc (a) ? ((a) + (dptr)) bytes: 1 cycles: 2 encoding: 1 0 0 1 0 0 1 1
semiconductor group 181 instruction set movc a, @a + pc operation: movc (pc) ? (pc) + 1 (a) ? ((a) + (pc)) bytes: 1 cycles: 2 encoding: 1 0 0 0 0 0 1 1
semiconductor group 182 instruction set movx , function: move external description: the movx instructions transfer data between the accumulator and a byte of external data memory, hence the x appended to mov. there are two types of instructions, differing in whether they provide an eight bit or sixteen-bit indirect address to the external data ram. in the first type, the contents of r0 or r1 in the current register bank provide an eight-bit address multiplexed with data on p0. eight bits are sufficient for external l/o expansion decoding or a relatively small ram array. for somewhat larger arrays, any output port pins can be used to output higher-order address bits. these pins would be controlled by an output instruction preceding the movx. in the second type of movx instructions, the data pointer generates a sixteen-bit address. p2 outputs the high-order eight address bits (the contents of dph) while p0 multiplexes the low-order eight bits (dpl) with data. the p2 special function register retains its previous contents while the p2 output buffers are emitting the contents of dph. this form is faster and more efficient when accessing very large data arrays (up to 64 kbyte), since no additional instructions are needed to set up the output ports. it is possible in some situations to mix the two movx types. a large ram array with its high-order address lines driven by p2 can be addressed via the data pointer, or with code to output high-order address bits to p2 followed by a movx instruction using r0 or r1. example: an external 256 byte ram using multiplexed address/data lines (e.g. an sab 8155 ram/i/o/timer) is connected to the sab 80(c)5xx port 0. port 3 provides control lines for the external ram. ports 1 and 2 are used for normal l/o. registers 0 and 1 contain 12 h and 34 h . location 34 h of the external ram holds the value 56 h . the instruction sequence movx a, @r1 movx @r0,a copies the value 56 h into both the accumulator and external ram location 12 h .
semiconductor group 183 instruction set movx a,@ri operation: movx (a) ? ((ri)) bytes: 1 cycles: 2 movx a,@dptr operation: movx (a) ? ((dptr)) bytes: 1 cycles: 2 movx @ri,a operation: movx ((ri)) ? (a) bytes: 1 cycles: 2 movx @dptr,a operation: movx ((dptr)) ? (a) bytes: 1 cycles: 2 encoding: 1 1 1 0 0 0 1 i encoding: 1 1 1 0 0 0 0 0 encoding: 1 1 1 1 0 0 1 i encoding: 1 1 1 1 0 0 0 0
semiconductor group 184 instruction set mul ab function: multiply description: mul ab multiplies the unsigned eight-bit integers in the accumulator and register b. the low-order byte of the sixteen-bit product is left in the accumulator, and the high-order byte in b. if the product is greater than 255 (0ff h ) the overflow flag is set; otherwise it is cleared. the carry flag is always cleared. example: originally the accumulator holds the value 80 (50 h ). register b holds the value 160 (0a0 h ). the instruction mul ab will give the product 12,800 (3200 h ), so b is changed to 32 h (00110010b) and the accumulator is cleared. the overflow flag is set, carry is cleared. operation: mul (a7-0) (b15-8) bytes: 1 cycles: 4 encoding: 1 0 1 0 0 1 0 0 ? (a) x (b)
semiconductor group 185 instruction set nop function: no operation description: execution continues at the following instruction. other than the pc, no registers or flags are affected. example: it is desired to produce a low-going output pulse on bit 7 of port 2 lasting exactly 5 cycles. a simple setb/clr sequence would generate a one-cycle pulse, so four additional cycles must be inserted. this may be done (assuming no interrupts are enabled) with the instruction sequence clr p2.7 nop nop nop nop setb p2.7 operation: nop bytes: 1 cycles: 1 encoding: 0 0 0 0 0 0 0 0
semiconductor group 186 instruction set orl function: logical or for byte variables description: orl performs the bitwise logical or operation between the indicated variables, storing the results in the destination byte. no flags are affected . the two operands allow six addressing mode combinations. when the destination is the accumulator, the source can use register, direct, register-indirect, or immediate addressing; when the destination is a direct address, the source can be the accumulator or immediate data. note: when this instruction is used to modify an output port, the value used as the original port data will be read from the output data latch, not the input pins. example: if the accumulator holds 0c3 h (11000011b) and r0 holds 55 h (01010101b) then the instruction orl a,r0 will leave the accumulator holding the value 0d7 h (11010111b). when the destination is a directly addressed byte, the instruction can set combinations of bits in any ram location or hardware register. the pattern of bits to be set is determined by a mask byte, which may be either a constant data value in the instruction or a variable computed in the accumulator at run-time. the instruction orl p1,#00110010b will set bits 5, 4, and 1 of output port 1. orl a,rn operation: orl (a) ? (a) (rn) bytes: 1 cycles: 1 encoding: 0 1 0 0 1 r r r
semiconductor group 187 instruction set orl a,direct operation: orl (a) ? (a) (direct) bytes: 2 cycles: 1 orl a,@ri operation: orl (a) ? (a) ((ri)) bytes: 1 cycles: 1 orl a,#data operation: orl (a) ? (a) #data bytes: 2 cycles: 1 orl direct,a operation: orl (direct) ? (direct) (a) bytes: 2 cycles: 1 encoding: 0 1 0 0 0 1 0 1 direct address encoding: 0 1 0 0 0 1 1 i encoding: 0 1 0 0 0 1 0 0 immediate data encoding: 0 1 0 0 0 0 1 0 direct address
semiconductor group 188 instruction set orl direct, #data operation: orl (direct) ? (direct) #data bytes: 3 cycles: 2 encoding: 0 1 0 0 0 0 1 1 direct address immediate data
semiconductor group 189 instruction set orl c, function: logical or for bit variables description: set the carry flag if the boolean value is a logic 1; leave the carry in its current state otherwise. a slash (/) preceding the operand in the assembly language indicates that the logical complement of the addressed bit is used as the source value, but the source bit itself is not affected. no other flags are affected. example: set the carry flag if, and only if, p1.0 = 1, acc.7 = 1, or ov = 0: mov c,p1.0 ; load carry with input pin p1.0 orl c,acc.7 ; or carry with the accumulator bit 7 orl c,/ov ; or carry with the inverse of ov orl c,bit operation: orl (c) ? (c) (bit) bytes: 2 cycles: 2 orl c,/bit operation: orl (c) ? (c) ? (bit) bytes: 2 cycles: 2 encoding: 0 1 1 1 0 0 1 0 bit address encoding: 1 0 1 0 0 0 0 0 bit address
semiconductor group 190 instruction set pop direct function: pop from stack description: the contents of the internal ram location addressed by the stack pointer is read, and the stack pointer is decremented by one. the value read is the transfer to the directly addressed byte indicated. no flags are affected. example: the stack pointer originally contains the value 32 h , and internal ram locations 30 h through 32 h contain the values 20 h , 23 h , and 01 h , respectively. the instruction sequence pop dph pop dpl will leave the stack pointer equal to the value 30 h and the data pointer set to 0123 h . at this point the instruction pop sp will leave the stack pointer set to 20 h . note that in this special case the stack pointer was decremented to 2f h before being loaded with the value popped (20 h ). operation: pop (direct) ? ((sp)) (sp) ? (sp) C 1 bytes: 2 cycles: 2 encoding: 1 1 0 1 0 0 0 0 direct address
semiconductor group 191 instruction set push direct function: push onto stack description: the stack pointer is incremented by one. the contents of the indicated variable is then copied into the internal ram location addressed by the stack pointer. otherwise no flags are affected. example: on entering an interrupt routine the stack pointer contains 09 h . the data pointer holds the value 0123 h . the instruction sequence push dpl push dph will leave the stack pointer set to 0b h and store 23 h and 01 h in internal ram locations 0a h and 0b h , respectively. operation: push (sp) ? (sp) + 1 ((sp)) ? (direct) bytes: 2 cycles: 2 encoding: 1 1 0 0 0 0 0 0 direct address
semiconductor group 192 instruction set ret function: return from subroutine description: ret pops the high and low-order bytes of the pc successively from the stack, decrementing the stack pointer by two. program execution continues at the resulting address, generally the instruction immediately following an acall or lcall. no flags are affected. example: the stack pointer originally contains the value 0b h . internal ram locations 0a h and 0b h contain the values 23 h and 01 h , respectively. the instruction ret will leave the stack pointer equal to the value 09 h . program execution will continue at location 0123 h . operation: ret (pc15-8) ? ((sp)) (sp) ? (sp) C 1 (pc7-0) ? ((sp)) (sp) ? (sp) C 1 bytes: 1 cycles: 2 encoding: 0 0 1 0 0 0 1 0
semiconductor group 193 instruction set reti function: return from interrupt description: reti pops the high and low-order bytes of the pc successively from the stack, and restores the interrupt logic to accept additional interrupts at the same priority level as the one just processed. the stack pointer is left decremented by two. no other registers are affected; the psw is not automatically restored to its pre-interrupt status. program execution continues at the resulting address, which is generally the instruction immediately after the point at which the interrupt request was detected. if a lower or same-level interrupt is pending when the reti instruction is executed, that one instruction will be executed before the pending interrupt is processed. example: the stack pointer originally contains the value 0b h . an interrupt was detected during the instruction ending at location 0122 h . internal ram locations 0a h and 0b h contain the values 23 h and 01 h , respectively. the instruction reti will leave the stack pointer equal to 09 h and return program execution to location 0123 h . operation: reti (pc15-8) ? ((sp)) (sp) ? (sp) C 1 (pc7-0) ? ((sp)) (sp) ? (sp) C 1 bytes: 1 cycles: 2 encoding: 0 0 1 1 0 0 1 0
semiconductor group 194 instruction set rl a function: rotate accumulator left description: the eight bits in the accumulator are rotated one bit to the left. bit 7 is rotated into the bit 0 position. no flags are affected. example: the accumulator holds the value 0c5 h (11000101b). the instruction rl a leaves the accumulator holding the value 8b h (10001011b) with the carry unaffected. operation: rl (an + 1) ? (an) n = 0-6 (a0) ? (a7) bytes: 1 cycles: 1 encoding: 0 0 1 0 0 0 1 1
semiconductor group 195 instruction set rlc a function: rotate accumulator left through carry flag description: the eight bits in the accumulator and the carry flag are together rotated one bit to the left. bit 7 moves into the carry flag; the original state of the carry flag moves into the bit 0 position. no other flags are affected. example: the accumulator holds the value 0c5 h (11000101b), and the carry is zero. the instruction rlc a leaves the accumulator holding the value 8a h (10001010b) with the carry set. operation: rlc (an + 1) ? (an) n = 0-6 (a0) ? (c) (c) ? (a7) bytes: 1 cycles: 1 encoding: 0 0 1 1 0 0 1 1
semiconductor group 196 instruction set rr a function: rotate accumulator right description: the eight bits in the accumulator are rotated one bit to the right. bit 0 is rotated into the bit 7 position. no flags are affected. example: the accumulator holds the value 0c5 h (11000101b). the instruction rr a leaves the accumulator holding the value 0e2 h (11100010b) with the carry unaffected. operation: rr (an) ? (an + 1) n = 0-6 (a7) ? (a0) bytes: 1 cycles: 1 encoding: 0 0 0 0 0 0 1 1
semiconductor group 197 instruction set rrc a function: rotate accumulator right through carry flag description: the eight bits in the accumulator and the carry flag are together rotated one bit to the right. bit 0 moves into the carry flag; the original value of the carry flag moves into the bit 7 position. no other flags are affected. example: the accumulator holds the value 0c5 h (11000101b), the carry is zero. the instruction rrc a leaves the accumulator holding the value 62 h (01100010b) with the carry set. operation: rrc (an) ? (an + 1) n=0-6 (a7) ? (c) (c) ? (a0) bytes: 1 cycles: 1 encoding: 0 0 0 1 0 0 1 1
semiconductor group 198 instruction set setb function: set bit description: setb sets the indicated bit to one. setb can operate on the carry flag or any directiy addressable bit. no other flags are affected. example: the carry flag is cleared. output port 1 has been written with the value 34 h (00110100b). the instructions setb c setb p1.0 will leave the carry flag set to 1 and change the data output on port 1 to 35 h (00110101b). setb c operation: setb (c) ? 1 bytes: 1 cycles: 1 setb bit operation: setb (bit) ? 1 bytes: 2 cycles: 1 encoding: 1 1 0 1 0 0 1 1 encoding: 1 1 0 1 0 0 1 0 bit address
semiconductor group 199 instruction set sjmp rel function: short jump description: program control branches unconditionally to the address indicated. the branch destination is computed by adding the signed displacement in the second instruction byte to the pc, after incrementing the pc twice. therefore, the range of destinations allowed is from 128 bytes preceding this instruction to 127 bytes following it. example: the label reladr is assigned to an instruction at program memory location 0123 h . the instruction sjmp reladr will assemble into location 0100 h . after the instruction is executed, the pc will contain the value 0123 h . note: under the above conditions the instruction following sjmp will be at 102 h . therefore, the displacement byte of the instruction will be the relative offset (0123 h - 0102 h ) = 21 h . in other words, an sjmp with a displacement of 0fe h would be a one-instruction infinite loop. operation: sjmp (pc) ? (pc) + 2 (pc) ? (pc) + rel bytes: 2 cycles: 2 encoding: 1 0 0 0 0 0 0 0 rel. address
semiconductor group 200 instruction set subb a, function: subtract with borrow description: subb subtracts the indicated variable and the carry flag together from the accumulator, leaving the result in the accumulator. subb sets the carry (borrow) flag if a borrow is needed for bit 7, and clears c otherwise. (if c was set before executing a subb instruction, this indicates that a borrow was needed for the previous step in a multiple precision subtraction, so the carry is subtracted from the accumulator along with the source operand). ac is set if a borrow is needed for bit 3, and cleared otherwise. ov is set if a borrow is needed into bit 6 but not into bit 7, or into bit 7 but not bit 6. when subtracting signed integers ov indicates a negative number produced when a negative value is subtracted from a positive value, or a positive result when a positive number is subtracted from a negative number. the source operand allows four addressing modes: register, direct, register- indirect, or immediate. example: the accumulator holds 0c9 h (11001001b), register 2 holds 54 h (01010100b), and the carry flag is set. the instruction subb a,r2 will leave the value 74 h (01110100b) in the accumulator, with the carry flag and ac cleared but ov set. notice that 0c9 h minus 54 h is 75 h . the difference between this and the above result is due to the (borrow) flag being set before the operation. if the state of the carry is not known before starting a single or multiple-precision subtraction, it should be explicitly cleared by a clr c instruction. subb a,rn operation: subb (a) ? (a) C (c) C (rn) bytes: 1 cycles: 1
semiconductor group 201 instruction set subb a,direct operation: subb (a) ? (a) C (c) C (direct) bytes: 2 cycles: 1 subb a, @ ri operation: subb (a) ? (a) C (c) C ((ri)) bytes: 1 cycles: 1 subb a, #data operation: subb (a) ? (a) C (c) C #data bytes: 2 cycles: 1 encoding: 1 0 0 1 0 1 0 1 direct address encoding: 1 0 0 1 0 1 1 i encoding: 1 0 0 1 0 1 0 0 immediate data
semiconductor group 202 instruction set swap a function: swap nibbles within the accumulator description: swap a interchanges the low and high-order nibbles (four-bit fields) of the accumulator (bits 3-0 and bits 7-4). the operation can also be thought of as a four- bit rotate instruction. no flags are affected. example: the accumulator holds the value 0c5 h (11000101b). the instruction swap a leaves the accumulator holding the value 5c h (01011100b). operation: swap (a3-0) (a7-4), (a7-4) ? (a3-0) bytes: 1 cycles: 1 encoding: 1 1 0 0 0 1 0 0 ? ?
semiconductor group 203 instruction set xch a, function: exchange accumulator with byte variable description: xch loads the accumulator with the contents of the indicated variable, at the same time writing the original accumulator contents to the indicated variable. the source/ destination operand can use register, direct, or register-indirect addressing. example: r0 contains the address 20 h . the accumulator holds the value 3f h (00111111b). internal ram location 20 h holds the value 75 h (01110101b). the instruction xch a, @r0 will leave ram location 20 h holding the value 3f h (00111111 b) and 75 h (01110101b) in the accumulator. xch a,rn operation: xch (a) (rn) bytes: 1 cycles: 1 xch a,direct operation: xch (a) (direct) bytes: 2 cycles: 1 encoding: 1 1 0 0 1 r r r encoding: 1 1 0 0 0 1 0 1 direct address ? ? ? ?
semiconductor group 204 instruction set xch a, @ ri operation: xch (a) ((ri)) bytes: 1 cycles: 1 encoding: 1 1 0 0 0 1 1 i ? ?
semiconductor group 205 instruction set xchd a,@ri function: exchange digit description: xchd exchanges the low-order nibble of the accumulator (bits 3-0, generally representing a hexadecimal or bcd digit), with that of the internal ram location indirectly addressed by the specified register. the high-order nibbles (bits 7-4) of each register are not affected. no flags are affected. example: r0 contains the address 20 h . the accumulator holds the value 36 h (00110110b). internal ram location 20 h holds the value 75 h (01110101b). the instruction xchd a, @ r0 will leave ram location 20 h holding the value 76 h (01110110b) and 35 h (00110101b) in the accumulator. operation: xchd (a3-0) ((ri)3-0) bytes: 1 cycles: 1 encoding: 1 1 0 1 0 1 1 i ? ?
semiconductor group 206 instruction set xrl , function: logical exclusive or for byte variables description: xrl performs the bitwise logical exclusive or operation between the indicated variables, storing the results in the destination. no flags are affected. the two operands allow six addressing mode combinations. when the destination is the accumulator, the source can use register, direct, register-indirect, or immediate addressing; when the destination is a direct address, the source can be accumulator or immediate data. note: when this instruction is used to modify an output port, the value used as the original port data will be read from the output data latch, not the input pins. example: if the accumulator holds 0c3 h (11000011b) and register 0 holds 0aa h (10101010b) then the instruction xrl a,r0 will leave the accumulator holding the value 69 h (01101001b). when the destination is a directly addressed byte, this instruction can complement combinations of bits in any ram location or hardware register. the pattern of bits to be complemented is then determined by a mask byte, either a constant contained in the instruction or a variable computed in the accumulator at run-time. the instruction xrl p1,#00110001b will complement bits 5, 4, and 0 of output port 1. xrl a,rn operation: xrl2 (a) ? (a) (rn) bytes: 1 cycles: 1 encoding: 0 1 1 0 1 r r r v
semiconductor group 207 instruction set xrl a,direct operation: xrl (a) ? (a) (direct) bytes: 2 cycles: 1 xrl a, @ ri operation: xrl (a) ? (a) ((ri)) bytes: 1 cycles: 1 xrl a, #data operation: xrl (a) ? (a) #data bytes: 2 cycles: 1 xrl direct,a operation: xrl (direct) ? (direct) (a) bytes: 2 cycles: 1 encoding: 0 1 1 0 0 1 0 1 direct address encoding: 0 1 1 0 0 1 1 i encoding: 0 1 1 0 0 1 0 0 immediate data encoding: 0 1 1 0 0 0 1 0 direct address v v v v
semiconductor group 208 instruction set xrl direct, #data operation: xrl (direct) ? (direct) #data bytes: 3 cycles: 2 encoding: 0 1 1 0 0 0 1 1 direct address immediate data v
semiconductor group 209 instruction set instruction set summary arithmetic operations mnemonic description byte cycle add a,rn add register to accumulator 1 1 add a,direct add direct byte to accumulator 2 1 add a, @ri add indirect ram to accumulator 1 1 add a,#data add immediate data to accumulator 2 1 addc a,rn add register to accumulator with carry flag 1 1 addc a,direct add direct byte to a with carry flag 2 1 addc a, @ri add indirect ram to a with carry flag 1 1 addc a, #data add immediate data to a with carry flag 2 1 subb a,rn subtract register from a with borrow 1 1 subb a,direct subtract direct byte from a with borrow 2 1 subb a,@ri subtract indirect ram from a with borrow 1 1 subb a,#data subtract immediate data from a with borrow 2 1 inc a increment accumulator 1 1 inc rn increment register 1 1 inc direct increment direct byte 2 1 inc @ri increment indirect ram 1 1 dec a decrement accumulator 1 1 dec rn decrement register 1 1 dec direct decrement direct byte 2 1 dec @ri decrement indirect ram 1 1 inc dptr increment data pointer 1 2 mul ab multiply a and b 1 4 div ab divide a by b 1 4 da a decimal adjust accumulator 1 1
semiconductor group 210 instruction set instruction set summary (contd) logic operations mnemonic description byte cycle anl a,rn and register to accumulator 1 1 anl a,direct and direct byte to accumulator 2 1 anl a,@ri and indirect ram to accumulator 1 1 anl a,#data and immediate data to accumulator 2 1 anl direct,a and accumulator to direct byte 2 1 anl direct,#data and immediate data to direct byte 3 2 orl a,rn or register to accumulator 1 1 orl a,direct or direct byte to accumulator 2 1 orl a,@ri or indirect ram to accumulator 1 1 orl a,#data or immediate data to accumulator 2 1 orl direct,a or accumulator to direct byte 2 1 orl direct,#data or immediate data to direct byte 3 2 xrl a,rn exclusive or register to accumulator 1 1 xrl a direct exclusive or direct byte to accumulator 2 1 xrl a,@ri exclusive or indirect ram to accumulator 1 1 xrl a,#data exclusive or immediate data to accumulator 2 1 xrl direct,a exclusive or accumulator to direct byte 2 1 xrl direct,#data exclusive or immediate data to direct byte 3 2 clr a clear accumulator 1 1 cpl a complement accumulator 1 1 rl a rotate accumulator left 1 1 rlc a rotate accumulator left through carry 1 1 rr a rotate accumulator right 1 1 rrc a rotate accumulator right through carry 1 1 swap a swap nibbles within the accumulator 1 1
semiconductor group 211 instruction set instruction set summary (contd) data transfer *) mov a,acc is not a valid instruction mnemonic description byte cycle mov a,rn move register to accumulator 1 1 mov a,direct *) move direct byte to accumulator 2 1 mov a,@ri move indirect ram to accumulator 1 1 mov a,#data move immediate data to accumulator 2 1 mov rn,a move accumulator to register 1 1 mov rn,direct move direct byte to register 2 2 mov rn,#data move immediate data to register 2 1 mov direct,a move accumulator to direct byte 2 1 mov direct,rn move register to direct byte 2 2 mov direct,direct move direct byte to direct byte 3 2 mov direct,@ri move indirect ram to direct byte 2 2 mov direct,#data move immediate data to direct byte 3 2 mov @ri,a move accumulator to indirect ram 1 1 mov @ri,direct move direct byte to indirect ram 2 2 mov @ri, #data move immediate data to indirect ram 2 1 mov dptr, #data16 load data pointer with a 16-bit constant 3 2 movc a,@a + dptr move code byte relative to dptr to accumulator 1 2 movc a,@a + pc move code byte relative to pc to accumulator 1 2 movx a,@ri move external ram (8-bit addr.) to a 1 2 movx a,@dptr move external ram (16-bit addr.) to a 1 2 movx @ri,a move a to external ram (8-bit addr.) 1 2 movx @dptr,a move a to external ram (16-bit addr.) 1 2 push direct push direct byte onto stack 2 2 pop direct pop direct byte from stack 2 2 xch a,rn exchange register with accumulator 1 1 xch a,direct exchange direct byte with accumulator 2 1 xch a,@ri exchange indirect ram with accumulator 1 1 xchd a,@ri exchange low-order nibble indir. ram with a 1 1
semiconductor group 212 instruction set instruction set summary (contd) boolean variable manipulation program and machine control mnemonic description byte cycle clr c clear carry flag 1 1 clr bit clear direct bit 2 1 setb c set carry flag 1 1 setb bit set direct bit 2 1 cpl c complement carry flag 1 1 cpl bit complement direct bit 2 1 anl c,bit and direct bit to carry flag 2 2 anl c,/bit and complement of direct bit to carry 2 2 orl c,bit or direct bit to carry flag 2 2 orl c,/bit or complement of direct bit to carry 2 2 mov c,bit move direct bit to carry flag 2 1 mov bit,c move carry flag to direct bit 2 2 acall addr11 absolute subroutine call 2 2 lcall addr16 long subroutine call 3 2 ret return from subroutine 1 2 reti return from interrupt 1 2 ajmp addr11 absolute jump 2 2 ljmp addr16 long iump 3 2 sjmp rel short jump (relative addr.) 2 2 jmp @a + dptr jump indirect relative to the dptr 1 2 jz rel jump if accumulator is zero 2 2 jnz rel jump if accumulator is not zero 2 2 jc rel jump if carry flag is set 2 2 jnc rel jump if carry flag is not set 2 2 jb bit,rel jump if direct bit is set 3 2 jnb bit,rel jump if direct bit is not set 3 2 jbc bit,rel jump if direct bit is set and clear bit 3 2 cjne a,direct,rel compare direct byte to a and jump if not equal 3 2
semiconductor group 213 instruction set instruction set summary (contd) program and machine control (contd) mnemonic description byte cycle cjne a,#data,rel compare immediate to a and jump if not equal 3 2 cjne rn,#data rel compare immed. to reg. and jump if not equal 3 2 cjne @ri,#data,rel compare immed. to ind. and jump if not equal 3 2 djnz rn,rel decrement register and jump if not zero 2 2 djnz direct,rel decrement direct byte and jump if not zero 3 2 nop no operation 1 1
semiconductor group 214 high-performance 8-bit cmos single-chip microcontroller sab 80c515/80c535 preliminary sab 80c515/80c515-16 cmos microcontroller with factory mask-programmable rom sab 80c535/80c535-16 cmos microcontroller for external rom l 8 k 8 rom (sab 80c515 only) l boolean processor l 256 8 ram l most instructions execute in 1 m s (750 ns) l six 8-bit i/o ports, one input port for l 4 m s (3 m s) multiply and divide digital or analog input l external memory expandable up to l three 16-bit timer/counters 128 kbytes l highly flexible reload, capture, compare l backwardly compatible with sab 8051 capabilities l functionally compatible with sab 80515 l full-duplex serial channel l idle and power-down mode l twelve interrupt vectors, four priority l plastic leaded chip carrier package: levels p-lcc-68 l 8-bit a/d converter with 8 multiplexed l plastic metric quad flat package inputs and programmable internal p-mqfp-80 reference voltages l two temperature ranges available: l 16-bit watchdog timer 0 to 70 c (for 12, 16, 20 mhz) C 40 to 85 c (for 12, 16 mhz) the sab 80c515/80c535 is a powerful member of the siemens sab 8051 family of 8-bit microcontrollers. it is designed in siemens acmos technology and is functionally compatible with the sab 80515/80535 devices designed in mymos technology. the sab 80c515/80c535 is a stand-alone, high-performance single-chip microcontroller based on the sab 8051/80c51 architecture. while maintaining all the sab 80c51 operating characteristics, the sab 80c515/80c535 incorporates several enhancements which significantly increase design flexibility and overall system performance. in addition, the low-power properties of siemens acmos technology allow applications where power consumption and dissipation are critical. furthermore, the sab 80c515/80c535 has two software-selectable modes of reduced activity for further power reduction: idle and power- down mode. the sab 80c535 is identical with the sab 80c515 except that it lacks the on-chip program memory. the sab 80c515/80c535 is supplied in a 68-pin plastic leaded chip carrier package (p-lcc-68) or in a plastic metric quad flat package (p-mqfp-80). there are versions for 12, 16 and 20 mhz operation and for extended temperature ranges C 40 to 85 c. versions for extended temperature range C 40 to + 110 c are available on request.
device specifications semiconductor group 215
device specifications semiconductor group 216 notes: versions for extended temperature range C 40 to + 110 c on request. the ordering number of rom types (dxxxx extension) is defined after program release (verification) of the customer. ordering information type ordering code package description 8-bit cmos microcontroller sab 80c515-n q 67120-dxxxx p-lcc-68 with mask-programmable rom, 12 mhz sab 80c535-n q 67120-c0508 p-lcc-68 for external memory, 12 mhz sab 80c515-n-t40/85 q 67120-dxxxx p-lcc-68 with mask-programmable rom, 12 mhz ext. temperature C 40 to + 85 c sab 80c535-n-t40/85 q 67120-c0510 p-lcc-68 for external memory, 12 mhz ext. temperature C 40 to + 85 c sab 80c515-16-n q 67120-dxxxx p-lcc-68 with mask-programmable rom, 16 mhz sab 80c535-16-n q 67120-c0509 p-lcc-68 for external memory, 16 mhz sab 80c535-16-n- t40/85 q 67120-c0562 p-lcc-68 for external memory, 16 mhz ext. temperature C 40 to + 85 c sab 80c535-20-n q 67120-c0778 p-lcc-68 for external memory, 20 mhz sab 80c535-m q67120-c0857 p-mqfp-80 for external memory, 12 mhz sab 80c515-m q67120-dxxxx p-mqfp-80 with mask-programmable rom, 12 mhz sab 80c535-m-t40/85 q67120-c0937 p-mqfp-80 for external memory, 12 mhz ext. temperature C 40 to + 85 c sab 80c515-m-t40/85 q67120-dxxxx p-mqfp-80 with mask-programmable rom, 12 mhz ext. temperature C 40 to + 85 c
device specifications semiconductor group 217 pin configuration (p-lcc-68 )
device specifications semiconductor group 218 pin configuration (p-mqfp-80 ) n.c. pins must not be connected. p0.6 / ad6 sab 80c535 / 80c515 80 1 p-mqfp-80 package 5 10 15 20 21 25 30 40 41 35 45 50 55 60 61 65 70 75 p0.7 / ad7 p0.5 / ad5 p0.4 / ad4 p0.2 / ad2 p0.3 / ad3 p0.1 / ad1 p0.0 / ad0 p5.7 n.c. ea ale psen p2.7 / a15 n.c. n.c. p2.6 / a14 p2.5 / a13 p2.4 / a12 p2.3 / a11 varef n.c. vagnd p6.7 / ain7 p6.5 / ain5 p6.6 / ain6 p6.4 / ain4 p6.3 / ain3 reset p6.2 / ain2 p6.0 / ain0 n.c. n.c. p3.1 / txd0 p6.1 / ain1 p3.0 / rxd0 p3.2 / int0 p3.3 / int1 p3.4 / t0 p3.5 / t1 n.c. p3.7 / rd p1.7 / t2 p1.6 / clkout p1.4 / int2 p1.5 / t2ex p1.3 / int6 / cc3 p1.2 / int5 / cc2 p3.6 / wr p1.1 / int4 / cc1 n.c. vcc vss xtal2 p1.0 / int3 / cc0 n.c. xtal1 p2.0 / a8 p2.1 / a9 p2.2 / a10 p4.5 p4.6 p4.4 p4.3 p4.2 pe p4.1 p4.0 p4.7 n.c. vcc n.c. p5.0 p5.2 n.c. p5.1 p5.3 p5.4 p5.5 p5.6
device specifications semiconductor group 219 logic symbol
device specifications semiconductor group 220 pin definitions and functions symbol pin p-lcc-68 pin p-mqfp-80 input (i) output (o) function p4.0-p4.7 1-3, 5-9 72-74, 76-80 i/o port 4 is an 8-bit bidirectional i/o port with internal pullup resistors. port 4 pins that have 1s written to them are pulled high by the internal pullup resistors, and in that state can be used as inputs. as inputs, port 4 pins being externally pulled low will source current ( i i l , in the dc characteristics) because of the internal pullup resistors. pe 475 i power saving mode enable a low level on this pin enables the use of the power saving modes (idle mode and power-down mode). when pe is held on high level it is impossible to enter the power saving modes. reset 10 1 i reset pin a low level on this pin for the duration of two machine cycles while the oscillator is running resets the sab 80c515. a small internal pullup resistor permits power-on reset using only a capacitor connected to v ss . v ar e f 11 3 reference voltage for the a/d converter v agnd 12 4 reference ground for the a/d converter p6.7-p6.0 13-20 5-12 port 6 is an 8-bit undirectional input port. port pins can be used for digital input if voltage levels simultaneously meet the specifications for high/low input voltages and for the eight multiplexed analog inputs of the a/d converter.
device specifications semiconductor group 221 pin definitions and functions (contd) symbol pin p-lcc-68 pin p-mqfp-80 input (i) output (o) function p3.0-p3.7 21-28 15-22 i/o port 3 is an 8-bit bidirectional i/o port with internal pullup resistors. port 3 pins that have1's written to them are pulled high by the internal pullup resistors, and in that state can be used as inputs. as inputs, port 3 pins being externally pulled low will source current ( i il , in the dc characteristics) because of the internal pullup resistors. port 3 also contains the interrupt, timer, serial port and external memory strobe pins that are used by various options. the output latch corresponding to a secondary function must be programmed to a one (1) for that function to operate. the secondary functions are assigned to the pins of port 3, as follows: C r d (p3.0): serial port's receiver data input (asynchronous) or data input/ output (synchronous) C t d (p3.1): serial port's transmitter data output (asynchronous) or clock output (synchronous) C int0 (p3.2): interrupt 0 input/timer 0 gate control input C int1 (p3.3): interrupt 1 input/timer 1 gate control input C t0 (p3.4): counter 0 input C t1 (p3.5): counter 1 input C wr (p3.6): the write control signal latches the data byte from port 0 into the external data memory C rd (p3.7): the read control signal enables the external data memory to port 0
device specifications semiconductor group 222 p1.7-p1.0 29-36 24-31 i/o port 1 is an 8-bit bidirectional i/o port with internal pullup resistors. port 1 pins that have 1's written to them are pulled high by the internal pullup resistors, and in that state can be used as inputs. as inputs, port 1 pins being externally pulled low will source current ( i i l in the dc characteristics) because of the internal pullup resistors. the port is used for the low-order address byte during program verification. port 1 also contains the interrupt, timer, clock, capture and compare pins that are used by various options. the output latch corresponding to a secondary function must be programmed to a one (1) for that function to operate (except when used for the compare functions). the secondary functions are assigned to the port 1 pins as follows: C int3 /cc0 (p1.0): interrupt 3 input/ compare 0 output/capture 0 input C int4/cc1 (p1.1): interrupt 4 input/ compare 1 output/capture 1 input C int5/cc2 (p1.2): interrupt 5 input/ compare 2 output/capture 2 input C int6/cc3 (p1.3): interrupt 6 input/ compare 3 output/capture 3 input C int2 (p1.4): interrupt 2 input C t2ex (p1.5): timer 2 external reload trigger input C clkout (p1.6): system clock output C t2 (p1.7): counter 2 input pin definitions and functions (contd) symbol pin p-lcc-68 pin p-mqfp-80 input (i) output (o) function
device specifications semiconductor group 223 xtal2 xtal1 39 40 36 37 xtal2 input to the inverting oscillator amplifier and input to the internal clock generator circuits. xtal1 output of the inverting oscillator amplifier. to drive the device from an external clock source, xtal2 should be driven, while xtal1 is left unconnected. there are no requirements on the duty cycle of the external clock signal, since the input to the internal clocking circuitry is divided down by a divide-by-two flip-flop. minimum and maximum high and low times and rise/fall times specified in the ac characteristics must be observed. p2.0-p2.7 41-48 38-45 i/o port 2 is an 8-bit bidirectional i/o port with internal pullup resistors. port 2 pins that have 1's written to them are pulled high by the internal pullup resistors, and in that state can be used as inputs. as inputs, port 2 pins being externally pulled low will source current ( i i l, in the dc characteristics) because of the internal pullup resistors. port 2 emits the high-order address byte during fetches from external program memory and during accesses to external data memory that use 16-bit addresses (movx@dptr). in this application it uses strong internal pullup resistors when issuing 1's. during accesses to external data memory that use 8-bit addresses (movx@ri), port 2 issues the contents of the p2 special function register. pin definitions and functions (contd) symbol pin p-lcc-68 pin p-mqfp-80 input (i) output (o) function
device specifications semiconductor group 224 psen 49 47 o the program store enable output is a control signal that enables the external program memory to the bus during external fetch operations. it is activated every six oscillator periods, except during external data memory accesses. the signal remains high during internal program execution. ale 50 48 o the address latch enable output is used for latching the address into external memory during normal operation. it is activated every six oscillator periods, except during an external data memory access. ea 51 49 i external access enable when held high, the sab 80c515 executes instructions from the internal rom as long as the pc is less than 8192. when held low, the sab 80c515 fetches all instructions from external program memory. for the sab 80c535 this pin must be tied low. p0.0-p0.7 52-59 52-59 i/o port 0 is an 8-bit open-drain bidirectional i/o port. port 0 pins that have 1's written to them float, and in that state can be used as high-impedance inputs. port 0 is also the multiplexed low-order address and data bus during accesses to external program and data memory. in this application it uses strong internal pullup resistors when issuing 1's. port 0 also outputs the code bytes during program verification in the sab 80c515. external pullup resistors are required during program verification. pin definitions and functions (contd) symbol pin p-lcc-68 pin p-mqfp-80 input (i) output (o) function
device specifications semiconductor group 225 p5.7-p5.0 60-67 60-67 i/o port 5 is an 8-bit bidirectional i/o port with internal pullup resistors. port 5 pins that have 1's written to them are pulled high by the internal pullup resistors, and in that state can be used as inputs. as inputs, port 5 pins being externally pulled low will source current ( i il in the dc characteristics) because of the internal pullup resistors. v cc 37 33 C supply voltage during normal, idle, and power-down operation. internally connected to pin 68. v ss 38 34 C ground (0 v) v cc 68 69 C supply voltage during normal, idle, and power-down operation. internally connected to pin 37. n. c. C 2, 13, 14, 23, 32, 35, 46, 50, 51, 68, 70, 71 C not connected these pins of the p-mqfp-80 package must not be connected pin definitions and functions (contd) symbol pin p-lcc-68 pin p-mqfp-80 input (i) output (o) function
device specifications semiconductor group 226 figure 1 block diagram
device specifications semiconductor group 227 functional description the members of the sab 80515 family of microcontrollers are: C sab 80c515: microcontroller, designed in siemens acmos technology, with 8 kbyte factory mask-programmable rom C sab 80c535: rom-less version of the sab 80c515 C sab 80515: microcontroller, designed in siemens mymos technology, with 8 kbyte factory mask-programmable rom C sab 80535: rom-less version of the sab 80515 the sab 80c535 is identical to the sab 80c515, except that it lacks the on-chip rom. in this data sheet the term "sab 80c515" is used to refer to both the sab 80c515 and sab 80c535, unless otherwise noted. principles of architecture the architecture of the sab 80c515 is based on the sab 8051/sab 80c51 microcontroller family. the following features of the sab 80c515 are fully compatible with the sab 80c51 features: C instruction set C external memory expansion interface (port 0 and port 2) C full-duplex serial port C timer/counter 0 and 1 C alternate functions on port 3 C the lower 128 bytes of internal ram and the lower 4 kbytes of internal rom the sab 80c515 additionally contains 128 bytes of internal ram and 4 kbytes of internal rom, which results in a total of 256 bytes of ram and 8 kbytes of rom on-chip. the sab 80c515 has a new 16-bit timer/counter with a 2:1 prescaler, reload mode, compare and capture capability. it also contains at 16-bit watchdog timer, an 8-bit a/d converter with programmable reference voltages, two additional quasi-bidirectional 8-bit ports, one 8-bit input port for analog or digital signals, and a programmable clock output ( f osc /12). furthermore, the sab 80c515 has a powerful interrupt structure with 12 vectors and 4 programmable priority levels. figure 1 shows a block diagram of the sab 80c515.
device specifications semiconductor group 228 cpu the sab 80c515 is efficient both as a controller and as an arithmetic processor. it has extensive facilities for binary and bcd arithmetic and excels in its bit-handling capabilities. efficient use of program memory results from an instruction set consisting of 44 % one-byte, 41 % two-byte, and 15 % three-byte instructions. with a 12 mhz crystal, 58 % of the instructions execute in 1.0 m s. memory organization the sab 80c515 manipulates operands in the four memory address spaces described below: figure 1 illustrates the memory address spaces of the sab 80c515. program memory the sab 80c515 has 8 kbyte of on-chip rom, while the sab 80c535 has no internal rom. the program memory can be externally expanded up to 64 kbytes. if the ea pin is held high, the sab 80c515 executes out of internal rom unless the address exceeds 1fff h . locations 2000 h through 0ffff h are then fetched from the external program memory. if the ea pin is held now, the sab 80c515 fetches all instructions from the external program memory. since the sab 80c535 has no internal rom, pin ea must be tied low when using this component. data memory the data memory address space consists of an internal and an external memory space. the internal data memory is divided into three physically separate and distinct blocks: the lower 128 bytes of ram, the upper 128 bytes of ram, and the 128 byte special function register (srf) area. while the upper 128 bytes of data memory and the sfr area share the same address locations, they are accessed through different addressing modes. the lower 128 bytes of data memory can be accessed through direct or register indirect addressing; the upper 128 bytes of ram can be accessed through register indirect addressing; the special function registers are accessible through direct addressing. four 8-register banks, each bank consisting of eight 8-bit multi-purpose registers, occupy locations 0 through 1f h in the lower ram area. the next 16 bytes, locations 20 h through 2f h , contain 128 directly addressable bit locations. the stack can be located anywhere in the internal data memory address space, and the stack depth can be expanded up to 256 bytes. the external data memory can be expanded up to 64 kbytes and can be accessed by instructions that use a 16-bit or an 8-bit address.
device specifications semiconductor group 229 figure 2 memory address spaces
device specifications semiconductor group 230 special function registers all registers, except the program counter and the four general purpose register banks, reside in the special function register area. the special function registers include arithmetic registers, pointers, and registers that provide an interface between the cpu and the on-chip peripherals. there are also 128 directly addressable bits within the sfr area. all special function registers are listed in table 1 and table 2. in table 1 they are organized in numeric order of their addresses. in table 3 they are organized in groups which refer to the functional blocks of the sab 80c515. table 1: special function register address register contents after reset address register contents after reset 80 h 81 h 82 h 83 h 84 h 85 h 86 h 87 h p0 1) sp dpl dph reserved reserved reserved pcon 0ff h 07 h 00 h 00 h xx h 2) xx h 2) xx h 2) 000x 0000 b 2) 98 h 99 h 9a h 9b h 9c h 9d h 9e h 9f h scon 1) sbuf reserved reserved reserved reserved reserved reserved 00 h xx h 2) xx h 2) xx h 2) xx h 2) xx h 2) xx h 2) xx h 2) 88 h 89 h 8a h 8b h 8c h 8d h 8e h 8f h tcon 1) tmod tl0 tl1 th0 th1 reserved reserved 00 h 00 h 00 h 00 h 00 h 00 h xx h 2) xx h 2) a0 h a1 h a2 h a3 h a4 h a5 h a6 h a7 h p2 1) reserved reserved reserved reserved reserved reserved reserved 0ff h xx h 2) xx h 2) xx h 2) xx h 2) xx h 2) xx h 2) xx h 2) 90 h 91 h 92 h 93 h 94 h 95 h 96 h 97 h p1 1) reserved reserved reserved reserved reserved reserved reserved 0ff h xx h 2) xx h 2) xx h 2) xx h 2) xx h 2) xx h 2) xx h 2) a8 h a9 h aa h ab h ac h ad h ae h af h ien0 1) ip0 reserved reserved reserved reserved reserved reserved 00 h x000 0000 b 2 ) xx h 2) xx h 2) xx h 2) xx h 2) xx h 2) xx h 2) 1) bit-addressable special function register 2) x means that the value is indeterminate and the location is reserved
device specifications semiconductor group 231 table 1:special function register (contd) address register contents after reset address register contents after reset b0 h b1 h b2 h b3 h b4 h b5 h b6 h b7 h p3 1) reserved reserved reserved reserved reserved reserved reserved 0ff h xx h 2) xx h 2) xx h 2) xx h 2) xx h 2) xx h 2) xx h 2) d0 h d1 h d2 h d3 h d4 h d5 h d6 h d7 h psw 1) reserved reserved reserved reserved reserved reserved reserved 00 h xx h 2) xx h 2) xx h 2) xx h 2) xx h 2) xx h 2) xx h 2) b8 h b9 h ba h bb h bc h bd h bs h bf h ien1 1) ip1 reserved reserved reserved reserved reserved reserved 00 h xx00 0000 b 2) xx h 2 ) xx h 2 ) xx h 2 ) xx h 2 ) xx h 2 ) xx h 2) d8 h d9 h da h db h dc h dd h de h df h adcon 1) addat dapr p6 reserved reserved reserved reserved 00x0 0000 b 2) 00 h 00 h xx h 2) xx h 2) xx h 2) xx h 2) xx h 2) c0 h c1 h c2 h c3 h c4 h c5 h c6 h c7 h ircon 1) ccen ccl1 cch1 ccl2 cch2 ccl3 cch3 00 h 00 h 00 h 00 h 00 h 00 h 00 h 00 h e0 h e1 h e2 h e3 h e4 h e5 h e6 h e7 h acc 1) reserved reserved reserved reserved reserved reserved reserved 00 h xx h 2) xx h 2) xx h 2) xx h 2) xx h 2) xx h 2) xx h 2) c8 h c9 h ca h cb h cc h cd h ce h cf h t2con 1) reserved crcl crch tl2 th2 reserved reserved 00 h xx h 2) 00 h 00 h 00 h 00 h xx h 2) xx h 2) e8 h e9 h ea h eb h ec h ed h ee h ef h p4 1) reserved reserved reserved reserved reserved reserved reserved 0ff h xx h 2) xx h 2) xx h 2) xx h 2) xx h 2) xx h 2) xx h 2) 1) bit-addressable special function register 2) x means that the value is indeterminate and the location is reserved
device specifications semiconductor group 232 f0 h f1 h f2 h f3 h f4 h f5 h f6 h f7 h b 1) reserved reserved reserved reserved reserved reserved reserved 00 h xx h 2) xx h 2) xx h 2) xx h 2) xx h 2) xx h 2) xx h 2) f8 h f9 h fa h fb h fc h fd h fe h ff h p5 1) reserved reserved reserved reserved reserved reserved reserved 0ff h xx h 2) xx h 2) xx h 2) xx h 2) xx h 2) xx h 2) xx h 2) 1) bit-addressable special function register 2) x means that the value is indeterminate and the location is reserved table 1:special function register (contd) address register contents after reset address register contents after reset
device specifications semiconductor group 233 table 2: special function registers - functional blocks block symbol name address contents after reset cpu acc b dph dpl psw sp accumulator b-register data pointer, high byte data pointer, low byte program status word register stack pointer 0e0 h 1) 0f0 h 1) 83 h 82 h 0d0 h 1) 81 h 00 h 00 h 00 h 00 h 00 h 07 h a/d- converter adcon addat dapr a/d converter control register a/d converter data register d/a converter program register 0d8 h 1) 0d9 h 0da h 00x0 0000 b 2) 00 h 00 h interrupt system en0 ien1 ip0 ip1 ircon tcon 2) t2con 2) interrupt enable register 0 interrupt enable register 1 interrupt priority register 0 interrupt priority register 1 interrupt request control register timer control register timer 2 control register 0a8 h 1) 0b8 h 1) 0a9 h 0b9 h 0c0 h 1) 88 h 1) 0c8 h 1) 00 h 00 h 00 h x000 0000 b 2) xx00 0000 b 3) 00 h 00 h 00 h compare/ capture- unit (ccu) ccen cch1 cch2 cch3 ccl1 ccl2 ccl3 crch crcl th2 tl2 t2con comp./capture enable reg. comp./capture reg. 1, high byte comp./capture reg. 2, high byte comp./capture reg. 3, high byte comp./capture reg. 1, low byte comp./capture reg. 2, low byte comp./capture reg. 3, low byte com./rel./capt. reg. high byte com./rel./capt. reg. low byte timer 2, high byte timer 2, low byte timer 2 control register 0c1 h 0c3 h 0c5 h 0c7 h 0c2 h 0c4 h 0c6 h 0cb h 0ca h 0cd h 0cc h 0c8 h 1) 00 h 00 h 00 h 00 h 00 h 00 h 00 h 00 h 00 h 00 h 00 h 00 h 1) bit-addressable special function registers 2) this special function register is listed repeatedly since some bits of it also belong to other functional blocks. 3) x means that the value is indeterminate and the location is reserved
device specifications semiconductor group 234 table 2: special function registers- functional blocks (contd) block symbol name address contents after reset ports p0 p1 p2 p3 p4 p5 p6 port 0 port 1 port 2 port 3 port 4 port 5 port 6, analog/digital input 80 h 1) 90 h 1) 0a0 h 1) 0b0 h 1) 0e8 h 1) 0f8 h 1) 0db h 0ff h 0ff h 0ff h 0ff h 0ff h 0ff h pow.sav.m odes pcon power control register 87 h 000x 0000 b 2) serial channels adcon 2) pcon 2) sbuf scon a/d converter control reg. power control register serial channel buffer reg. serial channel control reg. 0d8 h 1) 87 h 99 h 98 h 1) 00x0 0000 b 2) 000x 0000 b 2) 0xx h 3) 00 h timer 0/ timer 1 tcon th0 th1 tl0 tl1 tmod timer control register timer 0, high byte timer 1, high byte timer 0, low byte timer 1, low byte timer mode register 88 h 1) 8c h 8d h 8a h 8b h 89 h 00 h 00 h 00 h 00 h 00 h 00 h watchdog ien0 2) ien1 2) ip0 2) ip1 2) interrupt enable register 0 interrupt enable register 1 interrupt priority register 0 interrupt priority register 1 0a8 h 1) 0b8 h 1) 0a9 h 0b9 h 00 h 00 h x000 0000 b 2) xx00 0000 b 3) 1) bit-addressable special function registers 2) this special function register is listed repeatedly since some bits of it also belong to other functional blocks. 3) x means that the value is indeterminate and the location is reserved
device specifications semiconductor group 235 i/o ports the sab 80c515 has six 8-bit i/o ports and one 8-bit input port. port 0 is an open-drain bidirectional i/o port, while ports 1 to 5 are quasi-bidirectional i/o ports with internal pullup resistors. that means, when configured as inputs, ports 1 to 5 will be pulled high and will source current when externally pulled low. port 0 will float when configured as input. port 0 and port 2 can be used to expand the program and data memory externally. during an access to external memory, port 0 emits the low-order address byte and reads/writes the data byte, while port 2 emits the high-order address byte. in this function, port 0 is not an open-drain port, but uses a strong internal pullup fet. ports 1 and 3 are provided for several alternate functions, as listed below: the sab 80c515 has dual-purpose input port. as the anx lines in the sab 80515 (nmos version), the eight port lines at port 6 can be used as analog inputs. but if the input voltages at port 6 meet the specified digital input levels ( v il an d v ih ), the port can also be used as digital input port. reading the special function register p6 allows the user to input the digital values currently applied to the port pins. it is not necessary to select these modes by software; the voltages applied at port 6 pins can be converted to digital values using the a/d converter and at the same time the pins can be read via sfr p6. it must be noted, however, that the results in port p6 bits will be indeterminate if the levels at the corresponding pins are not within their respective v il / v ih specifications. furthermore, it is not possible to use port p6 as output lines. special function register p6 is located at address 0db h . port symbol function p1.0 p1.1 p1.2 p1.3 p1.4 p1.5 p1.6 p1.7 p3.0 p3.1 p3.2 p3.3 p3.4 p3.5 p3.6 p3.7 int3 /cc0 int4/cc1 int5/cc2 int6/cc3 int2 t2ex clkout t2 r d t d int0 int1 t0 t1 wr rd external interrupt 3 input, compare 0 output, capture 0 input external interrupt 4 input, compare 1 output, capture 1 input external interrupt 5 input, compare 2 output, capture 2 input external interrupt 6 input, compare 3 output, capture 3 input external interrupt 2 input timer 2 external reload trigger input system clock output timer 2 external count or gate input serial ports receiver data input (asynchronous) or data input/output (synchronous) serial ports transmitter data output (asynchronous) or clock output (synchronous) external interrupt 0 input, timer 0 gate control external interrupt 1 input, timer 1 gate control timer 0 external counter input timer 1 external counter input external data memory write strobe external data memory read strobe
device specifications semiconductor group 236 timer/counters the sab 80c515 contains three 16-bit timers/counters which are useful in many applications for timing and counting. the input clock for each timer/counter is 1/12 of the oscillator frequency in the timer operation or can be taken from an external clock source for the counter operation (maximum count rate is 1/24 of the oscillator frequency). C timer/counter 0 and 1 these timers/counters can operate in four modes: mode 0: 8-bit timer/counter with 32:1 prescaler mode 1: 16-bit timer/counter mode 2: 8-bit timer/counter with 8-bit auto-reload mode 3: timer/counter 0 is configured as one 8-bit timer/counter and one 8-bit timer; timer/counter 1 in this mode holds its count. external inputs int0 and int1 can be programmed to function as a gate for timer/counters 0 and 1 to facilitate pulse width measurements. C timer/counter 2 timer/counter 2 of the sab 80c515 is a 16-bit timer/counter with several additional features. it offers a 2:1 prescaler, a selectable gate function, and compare, capture and reload functions. corresponding to the 16-bit timer register there are four 16-bit capture/compare registers, one of them can be used to perform a 16-bit reload on a timer overflow or external event. each of these registers corresponds to a pin of port 1 for capture input/compare output. figure 3 shows a block diagram of timer/counter 2. reload a 16-bit reload can be performed with the 16-bit crc register consisting of crcl and crch. there are two modes from which to select: mode 0: reload is caused by a timer 2 overflow (auto-reload). mode 1: reload is caused in response to a negative transition at pin t2ex (p1.5), which can also request an interrupt. capture this feature permits saving the actual timer/counter contents into a selected register upon an external event or a software write operation. two modes are provided to latch the current 16-bit value in timer 2 registers tl2 and th2 into a dedicated capture register: mode 0: capture is performed in response to a transition at the corresponding port 1 pins cc0 to cc3. mode 1: write operation into the low-order byte of the dedicated capture register causes the timer 2 contents to be latched into this register.
device specifications semiconductor group 237 compare in the compare mode, the 16-bit values stored in the dedicated compare registers are compared to the contents of the timer 2 registers. if the count value in the timer 2 registers matches one of the stored values, an appropriate output signal is generated and an interrupt is requested. two compare modes are provided: mode 0: upon a match the output signal changes from low to high. it goes back to a low level when timer 2 overflows. mode 1: the transition of the output signal can be determined by software. a timer 2 overflow causes no output change . figure 3 block diagram of timer/counter 2
device specifications semiconductor group 238 serial port the serial port of the sab 80c515 enables full duplex communication between microcontrol- lers or between microcontroller and peripheral devices. the serial port can operate in 4 modes: mode 0: shift register mode. serial data enters and exits through r d. t d outputs the shift clock. 8-bits are transmitted/received: 8 data bits (lsb first). the baud rate is fixed at 1/12 of the oscillator frequency. mode 1: 10-bits are transmitted (through r d) or received (through t d): a start bit (0), 8 data bits (lsb first), and a stop bit (1). the baud rate is variable. mode 2: 11-bits are transmitted (through r d) or received (through t d): a start bit (0), 8 data bits (lsb first), a programmable 9th data bit, and a stop bit (1). the baud rate is programmable to either 1/32 or 1/64 of the oscillator frequency. mode 3: 11-bits are transmitted (through t d) or received (through r d): a start bit (0), 8 data bits (lsb first), a programmable 9th data bit, and a stop bit (1). mode 3 is identical to mode 2 except for the baud rate. the baud rate in mode 3 is variable. the variable baud rates in modes 1 and 3 can be generated by timer 1 or an internal baud rate generator. a/d converter the 8-bit a/d converter of the sab 80c515 has eight multiplexed analog inputs (port 6) and uses the successive approximation method. there are three characteristic time frames in a conversion cycle (see a/d converter characteristics): the conversion time t c , which is the time required for one conversion; the sample time t s which is included in the conversion time and is measured from the start of the conversion; the load time t l , which in turn is part of the sample time and also is measured from the conversion start. within the load time t l , the analog input capacitance c i must be loaded to the analog inpult voltage level. for the rest of the sample time t s , after the load time has passed, the selected analog input must be held constant. during the rest of the conversion time t c the conversion itself is actually performed. conversion can be programmed to be single or continuous; at the end of a conversion an interrupt can be generated. a unique feature is the capability of internal reference voltage programming. the internal reference voltages v i n t a r e f and v i n t a g n d for the a/d converter both are programmable to one of 16 steps with respect to the external reference voltages. this feature permits a conversion with a smaller internal reference voltage range to gain a higher resolution. in addition, the internal reference voltages can easily be adapted by software to the desired analog input voltage range. figure 4 shows a block diagram of the a/d converter.
device specifications semiconductor group 239 figure 4 block diagram of the a/d converter
device specifications semiconductor group 240 interrupt structure the sab 80c515 has 12 interrupt vectors with the following vector addresses and request flags: each interrupt vector can be individually enabled/disabled. the minimum response time to an interrupt request is more than 3 machine cycles and less than 9 machine cycles. figure 5 shows the interrupt request sources. external interrupts 0 and 1 can be activated by a low-level or a negative transition (selectable) at their corresponding input pin, external interrupts 2 and 3 can be programmed for triggering on a negative or a positive transition. the external interrupts 3 or 6 are combined with the corresponding alternate functions compare (output) and capture (input) on port 1. for programming of the priority levels the interrupt vectors are combined to pairs. each pair can be programmed individually to one of four priority levels by setting or clearing one bit in the special function register ip0 and one in ip1. figure 6 shows the priority level structure. table 3 interrupt sources and vectors source (request flags) vector address vector ie0 tf0 ie1 tf1 ri + ti tf2 + exf2 iadc iex2 iex3 iex4 iex5 iex6 0003 h 000b h 0013 h 001b h 0023 h 002b h 0043 h 004b h 0053 h 005b h 0063 h 006b h external interrupt 0 timer 0 interrupt external interrupt 1 timer 1 interrupt serial port interrupt timer 2 interrupt a/d converter interrupt external interrupt 2 external interrupt 3 external interrupt 4 external interrupt 5 external interrupt 6
device specifications semiconductor group 241 figure 5 interrupt request sources
device specifications semiconductor group 242 figure 6 interrupt priority level structure
device specifications semiconductor group 243 watchdog timer this feature is provided as a means of graceful recovery from a software upset. after an external reset, the watchdog timer is cleared and stopped. it can be started and cleared by software, but it cannot be stopped during active mode of the device. if the software fails to clear the watchdog timer at least every 65532 machine cycles (about 65 ms if a 12 mhz oscillator frequency is used), an internal reset will be initiated. the reset cause (external reset or reset caused by the watchdog) can be examined by software. to clear the watchdog, two bits in two different special function registers must be set by two consecutive instructions (bits ien0.6 and ien1.6). this is done to prevent the watchdog from being cleared by unexpected opcodes. it must be noted, however, that the watchdog timer is halted during the idle mode and power- down mode of the processor (see section "power saving modes" below). therefore, it is possible to use the idle mode in combination with the watchdog timer function. but even the watchdog timer cannot reset the device when one of the power saving modes has been is entered accidentally. for these reasons several precautions are taken against unintentional entering of the power- down or idle mode (see below). power saving modes the acmos technology of the sab 80c515 allows two new power saving modes of the device: the idle mode and the power-down mode. these modes replace the power-down supply mode via pin v pd of the sab 80515 (nmos). the sab 80c515 is supplied via pins v cc also during idle and power-down operation. however, there are applications where unintentional entering of these power saving modes must be absolutely avoided. such critical applications often use the watchdog timer to prevent the system from program upsets. then accidental entering of the power saving modes would even stop the watchdog timer and would circumvent the watchdog timer's task of system protection. thus, the sab 80c515 has an extra pin that allows it to disable both of the power saving modes. when pin pe is held high, idle mode and power-down mode are completely disabled and the instruction sequences that are used for entering these modes (see below) will not affect the normal operations of the device. when pe is held low, the use of the idle mode and power-down mode is possible as described in the following sections. pin pe has a weak internal pullup resistor. thus, when left open, the power saving modes are disabled. the special function register pcon in the nmos version sab 80515 the sfr pcon (address 87 h ) contains only bit smod; in the cmos version sab 80c515 there are more bits used (see table 4). the bits pde, pds and idle, idls select the power-down mode or the idle mode, respectively, when the use of the power saving modes is enabled by pin pe (see next page).
device specifications semiconductor group 244 if the power-down mode and the idle mode are set at the same time, power-down takes prece- dence. furthermore, register pcon contains two general purpose flags. for example, the flag bits gf0 and gf1 can be used to give an indication if an interrupt occurred during normal operation or during an idle. then an instruction that activates idle can also set one or both flag bits. when idle is terminated by an interrupt, the interrupt service routine can examine the flag bits. the reset value of pcon is 000x0000 b . idle mode in the idle mode the oscillator of the sab 80c515 continues to run, but the cpu is gated off from the clock signal. however, the interrupt system, the serial port, the a/d converter, and all timers with the exception of the watchdog timer are further provided with the clock. the cpu status is preserved in its entirety: the stack pointer, program counter, program status word, accumulator, and all other registers maintain their data during idle mode. the reduction of power consumption, which can be achieved by this feature depends on the number of peripherals running. table 4 sfr pcon (87 h ) smod pds idls C gf1 gf0 pde idle 87 h 7 6543210 symbol position function smod pds idls C gf1 gf0 pde idle pcon.7 pcon.6 pcon.5 pcon.4 pcon.3 pcon.2 pcon.1 pcon.0 when set, the baud rate of the serial channel in mode 1, 2, 3 is doubled. power-down start bit. the instruction that sets the pds flag bit is the last instruction before entering the power-down mode. idle start bit. the instruction that sets the idls flag bit is the last instruction before entering the idle mode. reserved general purpose flag general purpose flag power-down enable bit. when set, starting of the power- down mode is enabled. idle mode enable bit. when set, starting of the idle mode is enabled.
device specifications semiconductor group 245 if all timers are stopped and the a/d converter and the serial interface are not running, the maximum power reduction can be achieved. this state is also the test condition for the idle mode i cc (see dc characteristics, note 5). so the user has to take care which peripheral should continue to run and which has to be stopped during idle mode. also the state of all port pins C either the pins controlled by their latches or controlled by their secondary functions C depends on the status of the controller when entering idle mode. normally the port pins hold the logical state they had at the time idle mode was activated. if some pins are programmed to serve their alternate functions they still continue to output during idle mode if the assigned function is on. this applies to the compare outputs as well as to the clock output signal or to the serial interface in case it cannot finish reception or transmission during normal operation. the control signals ale and psen hold at logic high levels (see table 5). as in normal operation mode, the ports can be used as inputs during idle mode. thus a capture or reload operation can be triggered, the timers can be used to count external events, and external interrupts will be detected. the idle mode is a useful feature which makes it possible to "freeze" the processor's status C either for a predefined time, or until an external event reverts the controller to normal operation, as discussed below. the watchdog timer is the only peripheral which is automatically stopped during idle mode. if it were not disabled on entering idle mode, the watchdog timer would reset the controller, thus abandoning the idle mode. table 5 status of external pins during idle and power-down mode last instruction executed from internal code memory last instruction executed from external code memory outputs idle power-down idle power-down ale high low high low psen high low high low port 0 data data float float port 1 data/alternate outputs data/last output data/alternate outputs data/last output port 2 data data address data port 3 data/alternate outputs data/last output data/alternate outputs data/last output port 4 data data data data port 5 data data data data
device specifications semiconductor group 246 when idle mode is used, pin pe must be held on low level. the idle mode is then entered by two consecutive instructions. the first instruction sets the flag bit idle (pcon.0) and must not set bit idls (pcon.5), the following instruction sets the start bit idls (pcon.5) and must not set bit idle (pcon.0). the hardware ensures that a concurrent setting of both bits, idle and idls, does not initiate the idle mode. bits idle and idls will automatically be cleared after being set. if one of these register bits is read the value that appears is 0 (see table 4). this double instruction is implemented to minimize the chance of an unintentional entering of the idle mode which would leave the watchdog timers task of system protection without effect. note that pcon is not a bit-addressable register, so the above mentioned sequence for entering the idle mode is obtained by byte-handling instructions, as shown in the following example: orl pcon,#00000001 b ;set bit idle, bit idls must not be set orl pcon,#00100000 b ; set bit idls, bit idle must not be set the instruction that sets bit idls is the last instruction executed before going into idle mode. there are two ways to terminate the idle mode: C the idle mode can be terminated by activating any enable interrupt. this interrupt will be serviced and normally the instruction to be executed following the reti instruction will be the one following the instruction that sets the bit idls. C the other way to terminate the idle mode, is a hardware reset. since the oscillator is still running, the hardware reset must be held active only for two machine cycles for a complete reset. power-down mode in the power-down mode, the on-chip oscillator is stopped. therefore all functions are stopped; only the contents of the on-chip ram and the sfr's are maintained.the port pins controlled by their port latches output the values that are held by their sfr's. the port pins which serve the alternate output functions show the values they had at the end of the last cycle of the instruction which initiated the power-down mode; when the clockout signal (clkout, p1.6) is enabled, it will stop at low level. ale and psen hold at logic low level (see table 5). to enter the power-down mode the pin pe must be on low level. the power-down mode then is entered by two consecutive instructions. the first instruction has to set the flag bit pde (pcon.1) and must not set bit pds (pcon.6), the following instruction has to set the start bit pds (pcon.6) and must not set bit pde (pcon.1). the hardware ensures that a concurrent setting of both bits, pde and pds, does not initiate the power-down mode. bits pde and pds will automatically be cleared after having been set and the value shown by reading one of these bits is always 0 (see table 4). this double instruction is implemented to minimize the chance of unintentionally entering the power-down mode which could possibly "freeze" the chip's activity in an undesired status.
device specifications semiconductor group 247 note that pcon is not a bit-addressable register, so the above mentioned sequence for entering the power-down mode is obtained by byte-handling instructions, as shown in the following example: orl pcon,#00000010 b ;set bit pde, bit pds must not be set orl pcon,#01000000 b ;set bit pds, bit pde must not be set the instruction that sets bit pds is the last instruction executed before going into power-down mode. the only exit from power-down mode is a hardware reset. reset will redefine all sfr's, but will not change the contents of the internal ram. in the power-down mode of operation, v cc can be reduced to minimize power consumption. it must be ensured, however, that v cc is not reduced before the power- down mode is invoked, and that v cc is restored to its normal operating level, before the power-down mode is terminated. the reset signal that terminates the power-down mode also restarts the oscillator. the reset should not be activated before v cc is restored to its normal operating level and must be held active long enough to allow the oscillator to restart and stabilize (similar to power-on reset). differences in pin assignments of the sab 80c515 and sab 80515 since the sab 80c515 is designed in cmos technology, this device requires no v b b pin, be- cause the die's substrate is internally connected to v cc . furthermore, the ram backup power supply via pin v pd is replaced by the software- controlled power-down mode and power supply via v cc . therefore, pins v b b and v pd of the nmos version sab 80515 are used for other functions in the sab 80c515. pin 4 (the former pin v pd ) is the new pe pin which enables the use of the power saving modes. pin 37 (the former pin v bb ) becomes an additional v cc pin. thus, it is possible to insert a decoupling capacitor between pin 37 ( v cc ) and pin 38 ( v ss ) very close to the device, thereby avoiding long wiring and reducing the voltage distortion resulting from high dynamic current peaks. there is a difference between the nmos and cmos version concerning the clock circuitry. when the device is driven from an external source, pin xtal2 must be driven by the clock signal; pin xtal1, however, must be left open in the sab 80c515 (must be tied low in the nmos version). when using the oscillator with a crystal there is no difference in the circuitry. thus, due to its pin compatibility the sab 80c515 normally substitutes any sab 80515 without redesign of the users printed circuit board, but the user has to take care that the two v cc pins are hardwired on-chip. in any case, it is recommended that power is supplied on both v cc pins of the sab 80c515 to improve the power supply to the chip. if the power saving modes are to be used, pin pe must be tied low, otherwise these modes are disabled.
device specifications semiconductor group 248 instruction set the sab 80c515 / 83c535 has the same instruction set as the industry standard 8051 micro- controller. a pocket guide is available which contains the complete instruction set in functional and hexa- decimal order. furtheron it provides helpful information about special function registers, in- terrupt vectors and assembler directives. literature information title ordering no. microcontroller family sab 8051 pocket guide b158-h6579-x-x-7600
device specifications semiconductor group 249 absolute maximum ratings ambient temperature under bias sab 80c515 0 to 70 c sab 80c515-t3 C 40 to 85 c storage temperature C 65 to 150 c voltage on v cc pins with respect to ground ( v ss ) C 0.5 to 6.5 v voltage on any pin with respect to ground ( v ss ) C 0.5 to v cc + 0.5 v input current on any pin during overload condition C 10 ma to + 10 ma absolute sum of all input currents during overload condition |100 ma| power disipation 2 w note stresses above those listed under "absolute maximum ratings" may cause permanent damage of the device. this is a stress rating only and functional operation of the device at these or any other conditions above those indicated in the operational sections of this specification is not implied. exposure to absolute maximum rating conditions for longer periods may affect device reliability. during overload conditions ( v i n > v cc or v i n < v ss ) the voltage on v cc pins with respect to ground ( v ss ) must not exeed the values defined by the absolute maximum ratings. dc characteristics v cc = 5 v 10 %; v ss = 0 v t a = 0 to 70 c for the sab 80c515/80c535 t a = C 40 to 85 c for the sab 80c515/80c535-t3 parameter symbol limit values unit test condition min. max. input low voltage (except ea ) v i l C 0.5 0.2 v cc C 0.1 v C input low voltage (ea ) v i l1 C 0.5 0.2 v cc C 0.3 v C input high voltage (except reset and xtal 2) v i h 0.2 v cc + 0.9 v cc + 0.5 vC input high voltage to xtal2 v i h 1 0.7 v cc v cc + 0.5 vC input high voltage to reset v i h 2 0.6 v cc v cc + 0.5 vC output low voltage, ports 1, 2, 3, 4, 5 v ol C C 0.45 v i ol = 1.6 ma 1) notes see page 251.
device specifications semiconductor group 250 dc characteristics (contd) parameter symbol limit values unit test condition min. max. output low voltage, port 0, ale, psen v ol1 C 0.45 v i ol = 3.2 ma 1) output high voltage, ports 1, 2, 3, 4, 5 v oh 2.4 0.9 v c c C C v v i oh = C 80 m a i oh = C 10 m a output high voltage (port 0 in external bus mode, ale, psen) v oh 1 2.4 0.9 v c c C C v v i oh = C 400 m a i oh = C 40 m a 2) logic 0 input current, ports 1, 2, 3, 4, 5 i il C 10 C 70 m a v in = 0.45 v input low current to reset for reset i il2 C 10 C 100 m a v in = 0.45 v input low current (xtal2 ) i i l 3 C C 15 m a v in = 0.45 v input low current (pe ) i i l 4 C C 20 m a v in = 0.45 v logical 1-to-0 transition current, ports 1, 2, 3, 4, 5 i tl C 65 C 650 m a v in = 2 v input leakage current (port 0, port 6, an0-7, ea ) i l i C 1 m a0.45 < v i n < v cc pin capacitance c i o C 10 pf f c = 1 mhz, t a = 25 c power-supply current: active mode, 12 mhz 6) idle mode, 12 mhz 6) active mode, 16 mhz 6) idle mode, 16 mhz 6) power-down mode C i cc C i cc C i cc C i cc C i pd C C C C C 35 13 46 17 50 ma ma ma ma m a v cc = 5 v 4) v cc = 5 v 5) v cc = 5 v 4) v cc = 5 v 5) v cc = 2 v to 5.5 v 3) notes see page 251.
device specifications semiconductor group 251 notes for page 249 and 250: 1) capacitive loading on ports 0 and 2 may cause spurious noise pulses to be superimposed on the v ol of ale and ports 1, 3, 4 and 5. the noise is due to external bus capacitance discharging into the port 0 and port 2 pins when these pins make 1-to-0 transitions during bus operation. in the worst case (capacitive loading > 100 pf), the noise pulse on ale line may exceed 0.8 v. then, it may be desirable to qualify ale with a schmitttrigger, or use an address latch with a schmitttrigger strobe input. 2) capacitive loading on ports 0 and 2 may cause the voh on ale and psen to momentarily fall below the 0.9 v cc specification when the address bits are stabilizing. 3) power-down i cc is measured with: ea = port 0 = port 6 = v cc ; xtal1 = n.c.; xtal2 = v ss ; reset = v cc ; v agnd = v ss ; all other pins are disconnected. 4) i cc (active mode) is measured with: xtal2 driven with the clock signal according to the figure below; xtal1 = n.c.; ea = port 0 = port 6 = v cc ; reset = v ss ; all other pins are disconnected. i cc might be slightly higher if a crystal oscillator is used. 5) i cc (idle mode) is measured with: xtal2 driven with the clock signal according to the figure below; xtal1 = n.c.; ea = v ss ; port 0 = port 6 v cc ; reset = v cc ; all other pins are disconnected; all on-chip peripherals are disabled. 6) i cc at other frequencies is given by: active mode: i cc max (ma) = 2.67 f os c (mhz) + 3.00 idle mode: i cc max (ma) = 0.88 f os c (mhz) + 2.50 where f os c is the oscillator frequency in mhz. i cc max is given in ma and measured at v cc = 5 v (see also notes 4 and 5)
device specifications semiconductor group 252 a/d converter characteristics v cc = 5 v 10 %; v ss = 0 v; v are f = v cc 5 %; v ag n d = v ss 0.2 v; v i ntaref C v i ntagnd 3 1 v; t a = 0 to 70 c for sab 80c515/80c535 t a = C 40 to 85 c for sab 80c515/80c535-t40/85 parameter symbol limit values unit test condition min. typ. max. analog input voltage v ai n p ut v agnd C 0.2 C v ar e f + 0.2 v 9) analog input capacitance c i C 25 45 pf 7) load time t l C C 2 t cy m sC sample time (incl. load time) t s C C 7 t cy m sC conversion time (incl. sample time) t c C C 13 t cy m sC total unadjusted error tue C 1 2lsb v i n t ar e f = v aref = v cc v i n t ag nd = v ag n d = v ss 7) v aref supply current i ref C C 5 ma 8) internal reference error v i n t r ef e rr C 30 mv 8) 7) the output impedance of the analog source must be low enough to assure full loading of the sample capacitance ( c i ) during load time (t l ) . after charging of the internal capacitance ( c i ) i n the load time (t l ) the analog input must be held constant for the rest of the sample time (t s ) 8) the differential impedance r d of the analog reference voltage source must be less than 1 k w at reference supply voltage. 9) exceeding these limit values at one or more input channels will cause additional current which is sinked / sourced at these channels. this may also affect the accuracy of other channels which are operated within these specifications.
device specifications semiconductor group 253 ac characteristics v cc = 5 v 10%; v ss = 0 v ( c l for port 0, ale and psen outputs = 100 pf; c l for all outputs = 80 pf); t a = 0 to 70 c for sab 80c515/80c535 t a = C 40 to 85 c for sab 80c515/80c535-t40/85 parameter symbol limit values unit 12 mhz clock variable clock 1/ t clcl = 3.5 mhz to 12 mhz min. max. min. max. program memory characteristics ale pulse width t lhl l 127 C 2 t c lc l C 40 C ns address setup to ale t av ll 53 C t c l c l C 30 C ns address hold after ale t ll a x 48 C t c l c l C 35 C ns ale to valid instruction in t ll i v C 233 C 4 t c lc l C 100 ns ale to psen t ll p l 58 C t c l c l C 25 C ns psen pulse width t plp h 215 3 t c lc l C 35 ns psen to valid instruction in t pli v C 150 C 3 t c l c l C 100 ns input instruction hold after psen t px i x 0C0 C ns input instruction float after psen t px i z 1) C63 C t c l cl C 20 ns address valid after psen t pxav 1 ) 75 t c l c l C 8 ns address to valid instruc- tion in t a v i v C 302 C 5 t c l c l C 115 ns address float to psen t a z p l 0 C0 C ns 1) interfacing the sab 80c515 to devices with float times up to 75 ns is permissible. this limited bus contention will not cause any damage to port 0 drivers.
device specifications semiconductor group 254 ac characteristics (contd) parameter symbol limit values unit 12 mhz clock variable clock 1/ t clcl = 3.5 mhz to 12 mhz min. max. min. max. external data memory characteristics rd pulse width t rl r h 400 C 6 t clcl C 100 C ns wr pulse width t wl w h 400 C 6 t clcl C 100 C ns address hold after ale t ll a x 2 132 C 2 t clcl C 35 C ns rd to valid data in t rldv C 252 C 5 t clcl C 165 ns data hold after rd t rh d x 0C 0 ns data float after rd t rh d z C 97 C 2 t clcl C 70 ns ale to valid data in t ll d v C 517 C 8 t clcl C 150 ns address to valid data in t av d v C 585 C 9 t clcl C 165 ns ale to wr or rd t ll w l 200 300 3 t clcl C 50 3 t clcl + 50 ns wr or rd high to ale high t whl h 43 123 t clcl C 40 t clcl + 40 ns address valid to wr t av wl 203 C 4 t clcl C 130 C ns data valid to wr transition t qv w x 33 C t clcl C 50 C ns data setup before wr t qvwh 288 C 7 t clcl C 150 C ns data hold after wr t whqx 13 C t clcl C 50 C ns address float after rd t rlaz C0C 0 ns
device specifications semiconductor group 255 external clock cycle ac characteristics (contd) parameter symbol limit values unit variable clock frequ. = 3.5 mhz to 12 mhz min. max. external clock drive oscillator period t clcl 83.3 285 ns oscillator frequency 1/ t clcl 0.5 12 mhz high time t chcx 20 C ns low time t clcx 20 C ns rise time t clch C 20 ns fall time t chcl C 20 ns mct00033 t chcx t clcx chcl t clch t v cc t clcl - 0.5v 0.45v cc 0.7 v v - 0.1 cc 0.2
device specifications semiconductor group 256 system clock timing ac characteristics (contd) parameter symbol limit values unit 12 mhz clock variable clock 1/ t clcl = 3.5 mhz to 12 mhz min. max. min. max. system clock timing ale to clkout t llsh 543 C 7 t clcl C 40 C ns clkout high time t shsl 127 C 2 t clcl C 40 C ns clkout low time t slsh 793 C 10 t clcl C 40 C ns clkout low to ale high t sllh 43 123 t clcl C 40 t clcl + 40 ns
device specifications semiconductor group 257 ac characteristics for sab 80c515-16/80c535-16 v cc = 5 v 10 %; v ss = 0 v ( c l for port 0, ale and psen outputs = 100 pf; c l for all outputs = 80 pf) t a = 0 to 70 c for sab 80c515-16/80c535-16 t a = C 40 to 85 c for sab 80c515-16/80c535-16-t40/85 parameter symbol limit values unit 16 mhz clock variable clock 1/ t clcl = 3.5 mhz to 16 mhz min. max. min. max. program memory characteristics ale pulse width t lhll 85 C 2 t c lc l C 40 C ns address setup to ale t avll 33 C t clcl C 30 C ns address hold after ale t llax 28 C t clcl C 35 C ns ale to valid instruction in t lliv C 150 C 4 t clcl C 100 ns ale to psen t llpl 38 C t clcl C 25 C ns psen pulse width t plph 153 3 t clcl C 35 ns psen to valid instruction in t pliv C 88 C 3 t clcl C 100 ns input instruction hold after psen t pxix 0 C 0 C ns input instruction float after psen t pxiz 1) C 43 C t clcl C 20 ns address valid after psen t pxav 1 ) 55 t clcl C 8ns address to valid instruction in t aviv C 198 C 5 t clcl C 115 ns address float to psen t azpl 0 C 0 C ns 1) interfacing the sab 80c515-16 to devices with float times up to 55 ns is permissible. this limited bus contention will not cause any damage to port 0 drivers.
device specifications semiconductor group 258 ac characteristics (contd) parameter symbol limit values unit 16 mhz clock variable clock 1/ t clcl = 3.5 mhz to 16 mhz min. max. min. max. external data memory characteristics rd pulse width t rlrh 275 C 6 t clcl C 100 C ns wr pulse width t wlwh 275 C 6 t clcl C 100 C ns address hold after ale t llax2 90 C 2 t clcl C 35 C ns rd to valid data in t rldv C148C 5 t clcl C 165 ns data hold after rd t rhdx 0C0 C ns data float after rd t rhdz C55C 2 t clcl C 70 ns ale to valid data in t lldv C350C 8 t clcl C 150 ns address to valid data in t avdv C398C 9 t clcl C 165 ns ale to wr or rd t llwl 138 238 3 t clcl C 50 3 t clcl + 50 ns wr or rd high to ale high t whlh 23 103 t clcl C 40 t clcl + 40 ns address valid to wr t avwl 120 C 4 t clcl C 130 C ns data valid to wr transi- tion t qvwx 13 C t clcl C 50 C ns data setup before wr t qvwh 288 C 7 t clcl C 150 C ns data hold after wr t whqx 13 C t clcl C 50 C ns address float after rd t rlaz C0C 0 ns
device specifications semiconductor group 259 ac characteristics (contd) external clock cycle parameter symbol limit values unit variable clock frequ. = 3.5 mhz to 16 mhz min. max. external clock drive oscillator period t clcl 62.5 285 ns oscillator frequency 1/ t clcl 0.5 16 mhz high time t chcx 15 C ns low time t clcx 15 C ns rise time t clch C 15 ns fall time t chcl C 15 ns mct00033 t chcx t clcx chcl t clch t v cc t clcl - 0.5v 0.45v cc 0.7 v v - 0.1 cc 0.2
device specifications semiconductor group 260 system clock timing ac characteristics (contd) parameter symbol limit values unit 16 mhz clock variable clock 1/ t clcl = 3.5 mhz to 16 mhz min. max. min. max. system clock timing ale to clk out t llsh 398 C 7 t clcl C 40 C ns clk out high time t shsl 85 C 2 t clcl C 40 C ns clk out low time t slsh 585 C 10 t clcl C 40 C ns clk out low to ale high t sllh 23 103 t clcl C 40 t clcl + 40 ns
device specifications semiconductor group 261 ac characteristics for sab 80c515-20 / 80c535-20 v cc = 5 v 10 %; v ss = 0 v t a = 0 c t o + 70 c ( c l for port 0, ale and psen outputs = 100 pf; c l for all other outputs = 80 pf) * ) interfacing the sab 80c515 / 80c535 microcontrollers to devices with float times up to 45 ns is permissible. this limited bus contention will not cause any damage to port 0 drivers. parameter symbol limit values unit 20 mhz clock variable clock 1/ t clcl = 3.5 mhz to 20 mhz min. max. min. max. program memory characteristics ale pulse width t lhll 60 C 2 t clcl C 40 C ns address setup to ale t avll 20 C t clcl C 30 C ns address hold after ale t llax 20 C t clcl C 30 C ns ale low to valid instr in t lliv C100C 4 t clcl C 100 ns ale to psen t llpl 25 C t clcl C 25 C ns psen pulse width t plph 115 C 3 t clcl C 35 C ns psen to valid instr in t pliv C75C 3 t clcl C 75 ns input instruction hold after psen t pxix 0C0 C ns input instruction float after psen t pxiz * ) C40C t clcl C 10 ns address valid after psen t pxav * ) 47 C t clcl C 3 C ns address to valid instr in t aviv C190C 5 t clcl C 60 ns address float to psen t azpl 0C0 C ns
device specifications semiconductor group 262 ac characteristics (contd) parameter symbol limit values unit 20 mhz clock variable clock 1/ t clcl = 3.5 mhz to 20 mhz min. max. min. max. external data memory characteristics rd pulse width t rlrh 200 C 6 t clcl C 100 C ns wr pulse width t wlwh 200 C 6 t clcl C 100 C ns address hold after ale t llax2 65 C 2 t clcl C 35 C ns rd to valid data in t rldv C155C 5 t clcl C 95 ns data hold after rd t rhdx 0C0 C ns data float after rd t rhdz C40C 2 t clcl C 60 ns ale to valid data in t lldv C250C 8 t clcl C 150 ns address to valid data in t avdv C285C 9 t clcl C 165 ns ale to wr or rd t llwl 100 200 3 t clcl C 50 3 t clcl + 50 ns address valid to wr or rd t avwl 70 C 4 t clcl C 130 C ns wr or rd high to ale high t whlh 20 80 t clcl C 30 t clcl + 30 ns data valid to wr transition t qvwx 5C t clcl C 45 C ns data setup before wr t qvwh 200 C 7 t clcl C 150 C ns data hold after wr t whqx 10 C t clcl C 40 C ns address float after rd t rlaz C0C 0 ns
device specifications semiconductor group 263 ac characteristics (contd) external clock cycle parameter symbol limit values unit variable clock 1/ t clcl = 3.5 mhz to 20 mhz min. max. external clock drive oscillator period t clcl 50 285 ns high time t chcx 12 t clcl C t clcx ns low time t clcx 12 t clcl C t chcx ns rise time t clch C12ns fall time t chcl C12ns
device specifications semiconductor group 264 ac characteristics (contd) external clock cycle parameter symbol limit values unit 20 mhz clock variable clock 1/ t clcl = 3.5 mhz to 20 mhz min. max. min. max. system clock timing ale to clkout t llsh 310 C 7 t clcl C 40 C ns clkout high time t shsl 60 C 2 t clcl C 40 C ns clkout low time t slsh 460 C 10 t clcl C 40 C ns clkout low to ale high t sllh 10 90 t clcl C 40 t clcl + 40 ns
device specifications semiconductor group 265 rom verification characteristics t a = 25 c 5 c; v cc = 5 v 10 %; v ss = 0 v rom verification parameter symbol limit values unit min. max. rom verification address to valid data t avqv C 48 t clcl ns enable to valid data t elqv C 48 t clcl ns data float after enable t ehoz 048 t clcl ns oscillator frequency 1/ t clcl1 46mhz address to valid data t avqv C 48 t clcl ns mct00049 t avqv t ehqz t elqv address data out p1.0 - p1.7 p2.0 - p2.4 port 0 p2.7 enable inputs: p2.5 - p2.6, psen = ale, ea = reset = p0.0 - p0.7 = d0 - d7 data: p2.0 - p2.4 = a8 - a12 address: p1.0 - p1.7 = a0 - a7 v ih ss v v ss
device specifications semiconductor group 266 waveforms program memory read cycle data memory read cycle mct00096 ale psen port 2 lhll t a8 - a15 a8 - a15 a0 - a7 instr.in a0 - a7 port 0 t avll plph t t llpl t lliv t pliv t azpl t llax t pxiz t pxix t aviv t pxav mct00097 ale psen port 2 whlh t port 0 rd t lldv t rlrh t llwl t rldv t avll t llax2 t rlaz t avwl t avdv t rhdx t rhdz a0 - a7 from ri or dpl from pcl a0 - a7 instr. in data in a8 - a15 from pch p2.0 - p2.7 or a8 - a15 from dph
device specifications semiconductor group 267 data memory write cycle recommended oscillator circuits mct00098 ale psen port 2 whlh t port 0 wr t wlwh t llwl t qvwx t avll t llax2 t qvwh t avwl t whqx a0 - a7 from ri or dpl from pcl a0 - a7 instr.in data out a8 - a15 from pch p2.0 - p2.7 or a8 - a15 from dph ac inputs during testing are driven at v c c C 0.5 v for a logic '1' and 0.45 v for a logic '0'. timing measurements are made at v i h min for a logic '1' and v i l max for a logic '0'. for timing purposes a port pin is no longer floating when a 100 mv change from load voltage occurs and begins to float when a 100 mv deviation from the load voltage v o h / v o l occurs. i o l / i o h 3 20 ma.
device specifications semiconductor group 268 ac testing: input, output waveforms ac testing: float waveforms
device specifications semiconductor group 269 package outlines plastic package, p-lcc-68 C smd (plastic leaded chip-carrier) sorts of packing package outlines for tubes, trays etc. are contained in our data book package information. dimensions in mm smd = surface mounted device
device specifications semiconductor group 270 package outlines plastic package, p-mqfp-80 C smd (plastic metric quad flat package) sorts of packing package outlines for tubes, trays etc. are contained in our data book package information. dimensions in mm smd = surface mounted device


▲Up To Search▲   

 
Price & Availability of SAB80C535-16-N-T85

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X